Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
26 :
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>
42 :
43 : namespace
44 : {
45 0 : void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
46 : {
47 0 : if ( _nIndex < 0 || _nIndex > _sText.getLength() )
48 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
49 0 : }
50 : }
51 :
52 : // class VCLXAccessibleListItem ------------------------------------------
53 :
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;
59 :
60 : // -----------------------------------------------------------------------------
61 : // Ctor() and Dtor()
62 : // -----------------------------------------------------------------------------
63 0 : VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) :
64 :
65 : VCLXAccessibleListItem_BASE ( m_aMutex ),
66 :
67 : m_nIndexInParent( _nIndexInParent ),
68 : m_bSelected ( sal_False ),
69 : m_bVisible ( sal_False ),
70 : m_nClientId ( 0 ),
71 : m_pListBoxHelper( _pListBoxHelper ),
72 0 : m_xParent ( _xParent )
73 :
74 : {
75 0 : if ( m_xParent.is() )
76 0 : m_xParentContext = m_xParent->getAccessibleContext();
77 :
78 0 : if ( m_pListBoxHelper )
79 0 : m_sEntryText = m_pListBoxHelper->GetEntry( (sal_uInt16)_nIndexInParent );
80 0 : }
81 : // -----------------------------------------------------------------------------
82 0 : VCLXAccessibleListItem::~VCLXAccessibleListItem()
83 : {
84 0 : }
85 : // -----------------------------------------------------------------------------
86 0 : void VCLXAccessibleListItem::SetSelected( sal_Bool _bSelected )
87 : {
88 0 : if ( m_bSelected != _bSelected )
89 : {
90 0 : Any aOldValue;
91 0 : Any aNewValue;
92 0 : if ( m_bSelected )
93 0 : aOldValue <<= AccessibleStateType::SELECTED;
94 : else
95 0 : aNewValue <<= AccessibleStateType::SELECTED;
96 0 : m_bSelected = _bSelected;
97 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
98 : }
99 0 : }
100 : // -----------------------------------------------------------------------------
101 0 : void VCLXAccessibleListItem::SetVisible( sal_Bool _bVisible )
102 : {
103 0 : if ( m_bVisible != _bVisible )
104 : {
105 0 : Any aOldValue, aNewValue;
106 0 : m_bVisible = _bVisible;
107 0 : (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
108 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
109 0 : (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
110 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
111 : }
112 0 : }
113 : // -----------------------------------------------------------------------------
114 0 : void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId,
115 : const ::com::sun::star::uno::Any& _aOldValue,
116 : const ::com::sun::star::uno::Any& _aNewValue )
117 : {
118 0 : AccessibleEventObject aEvt;
119 0 : aEvt.Source = *this;
120 0 : aEvt.EventId = _nEventId;
121 0 : aEvt.OldValue = _aOldValue;
122 0 : aEvt.NewValue = _aNewValue;
123 :
124 0 : if (m_nClientId)
125 0 : comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt );
126 0 : }
127 : // -----------------------------------------------------------------------------
128 : // OCommonAccessibleText
129 : // -----------------------------------------------------------------------------
130 0 : OUString VCLXAccessibleListItem::implGetText()
131 : {
132 0 : return m_sEntryText;
133 : }
134 : // -----------------------------------------------------------------------------
135 0 : Locale VCLXAccessibleListItem::implGetLocale()
136 : {
137 0 : return Application::GetSettings().GetLanguageTag().getLocale();
138 : }
139 : // -----------------------------------------------------------------------------
140 0 : void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
141 : {
142 0 : nStartIndex = 0;
143 0 : nEndIndex = 0;
144 0 : }
145 : // -----------------------------------------------------------------------------
146 : // XInterface
147 : // -----------------------------------------------------------------------------
148 0 : Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException)
149 : {
150 0 : return VCLXAccessibleListItem_BASE::queryInterface( rType );
151 : }
152 : // -----------------------------------------------------------------------------
153 0 : void SAL_CALL VCLXAccessibleListItem::acquire() throw ()
154 : {
155 0 : VCLXAccessibleListItem_BASE::acquire();
156 0 : }
157 : // -----------------------------------------------------------------------------
158 0 : void SAL_CALL VCLXAccessibleListItem::release() throw ()
159 : {
160 0 : VCLXAccessibleListItem_BASE::release();
161 0 : }
162 : // -----------------------------------------------------------------------------
163 : // XTypeProvider
164 : // -----------------------------------------------------------------------------
165 0 : Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes( ) throw (RuntimeException)
166 : {
167 0 : return VCLXAccessibleListItem_BASE::getTypes();
168 : }
169 : // -----------------------------------------------------------------------------
170 0 : Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException)
171 : {
172 : static ::cppu::OImplementationId* pId = NULL;
173 :
174 0 : if ( !pId )
175 : {
176 0 : ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
177 :
178 0 : if ( !pId )
179 : {
180 0 : static ::cppu::OImplementationId aId;
181 0 : pId = &aId;
182 0 : }
183 : }
184 0 : return pId->getImplementationId();
185 : }
186 : // -----------------------------------------------------------------------------
187 : // XComponent
188 : // -----------------------------------------------------------------------------
189 0 : void SAL_CALL VCLXAccessibleListItem::disposing()
190 : {
191 0 : comphelper::AccessibleEventNotifier::TClientId nId( 0 );
192 0 : Reference< XInterface > xEventSource;
193 : {
194 0 : ::osl::MutexGuard aGuard( m_aMutex );
195 :
196 0 : VCLXAccessibleListItem_BASE::disposing();
197 0 : m_sEntryText = OUString();
198 0 : m_pListBoxHelper = NULL;
199 0 : m_xParent = NULL;
200 0 : m_xParentContext = NULL;
201 :
202 0 : nId = m_nClientId;
203 0 : m_nClientId = 0;
204 0 : if ( nId )
205 0 : xEventSource = *this;
206 : }
207 :
208 : // Send a disposing to all listeners.
209 0 : if ( nId )
210 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
211 0 : }
212 : // -----------------------------------------------------------------------------
213 : // XServiceInfo
214 : // -----------------------------------------------------------------------------
215 0 : OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException)
216 : {
217 0 : return OUString( "com.sun.star.comp.toolkit.AccessibleListItem" );
218 : }
219 : // -----------------------------------------------------------------------------
220 0 : sal_Bool VCLXAccessibleListItem::supportsService( const OUString& rServiceName ) throw (RuntimeException)
221 : {
222 0 : return cppu::supportsService(this, rServiceName);
223 : }
224 : // -----------------------------------------------------------------------------
225 0 : Sequence< OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException)
226 : {
227 0 : Sequence< OUString > aNames(3);
228 0 : aNames[0] = "com.sun.star.accessibility.AccessibleContext";
229 0 : aNames[1] = "com.sun.star.accessibility.AccessibleComponent";
230 0 : aNames[2] = "com.sun.star.accessibility.AccessibleListItem";
231 0 : return aNames;
232 : }
233 : // -----------------------------------------------------------------------------
234 : // XAccessible
235 : // -----------------------------------------------------------------------------
236 0 : Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext( ) throw (RuntimeException)
237 : {
238 0 : return this;
239 : }
240 : // -----------------------------------------------------------------------------
241 : // XAccessibleContext
242 : // -----------------------------------------------------------------------------
243 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount( ) throw (RuntimeException)
244 : {
245 0 : return 0;
246 : }
247 : // -----------------------------------------------------------------------------
248 0 : Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException)
249 : {
250 0 : return Reference< XAccessible >();
251 : }
252 : // -----------------------------------------------------------------------------
253 0 : Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent( ) throw (RuntimeException)
254 : {
255 0 : ::osl::MutexGuard aGuard( m_aMutex );
256 :
257 0 : return m_xParent;
258 : }
259 : // -----------------------------------------------------------------------------
260 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent( ) throw (RuntimeException)
261 : {
262 0 : ::osl::MutexGuard aGuard( m_aMutex );
263 0 : return m_nIndexInParent;
264 : }
265 : // -----------------------------------------------------------------------------
266 0 : sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole( ) throw (RuntimeException)
267 : {
268 0 : return AccessibleRole::LIST_ITEM;
269 : // return AccessibleRole::LABEL;
270 : }
271 : // -----------------------------------------------------------------------------
272 0 : OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription( ) throw (RuntimeException)
273 : {
274 : // no description for every item
275 0 : return OUString();
276 : }
277 : // -----------------------------------------------------------------------------
278 0 : OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName( ) throw (RuntimeException)
279 : {
280 0 : ::osl::MutexGuard aGuard( m_aMutex );
281 :
282 : // entry text == accessible name
283 0 : return implGetText();
284 : }
285 : // -----------------------------------------------------------------------------
286 0 : Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet( ) throw (RuntimeException)
287 : {
288 0 : utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
289 0 : Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
290 0 : return xSet;
291 : }
292 : // -----------------------------------------------------------------------------
293 0 : Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet( ) throw (RuntimeException)
294 : {
295 0 : ::osl::MutexGuard aGuard( m_aMutex );
296 :
297 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
298 0 : Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
299 :
300 0 : if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
301 : {
302 0 : pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
303 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
304 0 : pStateSetHelper->AddState( AccessibleStateType::ENABLED );
305 0 : pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
306 0 : if ( m_bSelected )
307 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTED );
308 0 : if ( m_bVisible )
309 : {
310 0 : pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
311 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
312 : }
313 : }
314 : else
315 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
316 :
317 0 : return xStateSet;
318 : }
319 : // -----------------------------------------------------------------------------
320 0 : Locale SAL_CALL VCLXAccessibleListItem::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
321 : {
322 0 : SolarMutexGuard aSolarGuard;
323 0 : ::osl::MutexGuard aGuard( m_aMutex );
324 :
325 0 : return implGetLocale();
326 : }
327 : // -----------------------------------------------------------------------------
328 : // XAccessibleComponent
329 : // -----------------------------------------------------------------------------
330 0 : sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException)
331 : {
332 0 : SolarMutexGuard aSolarGuard;
333 0 : ::osl::MutexGuard aGuard( m_aMutex );
334 :
335 0 : sal_Bool bInside = sal_False;
336 0 : if ( m_pListBoxHelper )
337 : {
338 0 : Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
339 0 : aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y());
340 0 : bInside = aRect.IsInside( VCLPoint( _aPoint ) );
341 : }
342 0 : return bInside;
343 : }
344 : // -----------------------------------------------------------------------------
345 0 : Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
346 : {
347 0 : return Reference< XAccessible >();
348 : }
349 : // -----------------------------------------------------------------------------
350 0 : awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds( ) throw (RuntimeException)
351 : {
352 0 : SolarMutexGuard aSolarGuard;
353 0 : ::osl::MutexGuard aGuard( m_aMutex );
354 :
355 0 : awt::Rectangle aRect;
356 0 : if ( m_pListBoxHelper )
357 0 : aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
358 :
359 0 : return aRect;
360 : }
361 : // -----------------------------------------------------------------------------
362 0 : awt::Point SAL_CALL VCLXAccessibleListItem::getLocation( ) throw (RuntimeException)
363 : {
364 0 : SolarMutexGuard aSolarGuard;
365 0 : ::osl::MutexGuard aGuard( m_aMutex );
366 :
367 0 : Point aPoint(0,0);
368 0 : if ( m_pListBoxHelper )
369 : {
370 0 : Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
371 0 : aPoint = aRect.TopLeft();
372 : }
373 0 : return AWTPoint( aPoint );
374 : }
375 : // -----------------------------------------------------------------------------
376 0 : awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen( ) throw (RuntimeException)
377 : {
378 0 : SolarMutexGuard aSolarGuard;
379 0 : ::osl::MutexGuard aGuard( m_aMutex );
380 :
381 0 : Point aPoint(0,0);
382 0 : if ( m_pListBoxHelper )
383 : {
384 0 : Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
385 0 : aPoint = aRect.TopLeft();
386 0 : aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft();
387 : }
388 0 : return AWTPoint( aPoint );
389 : }
390 : // -----------------------------------------------------------------------------
391 0 : awt::Size SAL_CALL VCLXAccessibleListItem::getSize( ) throw (RuntimeException)
392 : {
393 0 : SolarMutexGuard aSolarGuard;
394 0 : ::osl::MutexGuard aGuard( m_aMutex );
395 :
396 0 : Size aSize;
397 0 : if ( m_pListBoxHelper )
398 0 : aSize = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize();
399 :
400 0 : return AWTSize( aSize );
401 : }
402 : // -----------------------------------------------------------------------------
403 0 : void SAL_CALL VCLXAccessibleListItem::grabFocus( ) throw (RuntimeException)
404 : {
405 : // no focus for each item
406 0 : }
407 : // -----------------------------------------------------------------------------
408 : // XAccessibleText
409 : // -----------------------------------------------------------------------------
410 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException)
411 : {
412 0 : return -1;
413 : }
414 : // -----------------------------------------------------------------------------
415 0 : sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
416 : {
417 0 : SolarMutexGuard aSolarGuard;
418 0 : ::osl::MutexGuard aGuard( m_aMutex );
419 :
420 0 : if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
421 0 : throw IndexOutOfBoundsException();
422 :
423 0 : return sal_False;
424 : }
425 : // -----------------------------------------------------------------------------
426 0 : sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
427 : {
428 0 : SolarMutexGuard aSolarGuard;
429 0 : ::osl::MutexGuard aGuard( m_aMutex );
430 :
431 0 : return OCommonAccessibleText::getCharacter( nIndex );
432 : }
433 : // -----------------------------------------------------------------------------
434 0 : Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
435 : {
436 0 : SolarMutexGuard aSolarGuard;
437 0 : ::osl::MutexGuard aGuard( m_aMutex );
438 :
439 0 : OUString sText( implGetText() );
440 0 : if ( !implIsValidIndex( nIndex, sText.getLength() ) )
441 0 : throw IndexOutOfBoundsException();
442 :
443 0 : return Sequence< PropertyValue >();
444 : }
445 : // -----------------------------------------------------------------------------
446 0 : awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
447 : {
448 0 : SolarMutexGuard aSolarGuard;
449 0 : ::osl::MutexGuard aGuard( m_aMutex );
450 :
451 0 : OUString sText( implGetText() );
452 0 : if ( !implIsValidIndex( nIndex, sText.getLength() ) )
453 0 : throw IndexOutOfBoundsException();
454 :
455 0 : awt::Rectangle aBounds( 0, 0, 0, 0 );
456 0 : if ( m_pListBoxHelper )
457 : {
458 0 : Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex );
459 0 : Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
460 0 : aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
461 0 : aBounds = AWTRectangle( aCharRect );
462 : }
463 :
464 0 : return aBounds;
465 : }
466 : // -----------------------------------------------------------------------------
467 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException)
468 : {
469 0 : SolarMutexGuard aSolarGuard;
470 0 : ::osl::MutexGuard aGuard( m_aMutex );
471 :
472 0 : return OCommonAccessibleText::getCharacterCount();
473 : }
474 : // -----------------------------------------------------------------------------
475 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
476 : {
477 0 : SolarMutexGuard aSolarGuard;
478 0 : ::osl::MutexGuard aGuard( m_aMutex );
479 :
480 0 : sal_Int32 nIndex = -1;
481 0 : if ( m_pListBoxHelper )
482 : {
483 0 : sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
484 0 : Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
485 0 : Point aPnt( VCLPoint( aPoint ) );
486 0 : aPnt += aItemRect.TopLeft();
487 0 : sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos );
488 0 : if ( nI != -1 && (sal_uInt16)m_nIndexInParent == nPos )
489 0 : nIndex = nI;
490 : }
491 0 : return nIndex;
492 : }
493 : // -----------------------------------------------------------------------------
494 0 : OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException)
495 : {
496 0 : SolarMutexGuard aSolarGuard;
497 0 : ::osl::MutexGuard aGuard( m_aMutex );
498 :
499 0 : return OCommonAccessibleText::getSelectedText();
500 : }
501 : // -----------------------------------------------------------------------------
502 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException)
503 : {
504 0 : SolarMutexGuard aSolarGuard;
505 0 : ::osl::MutexGuard aGuard( m_aMutex );
506 :
507 0 : return OCommonAccessibleText::getSelectionStart();
508 : }
509 : // -----------------------------------------------------------------------------
510 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException)
511 : {
512 0 : SolarMutexGuard aSolarGuard;
513 0 : ::osl::MutexGuard aGuard( m_aMutex );
514 :
515 0 : return OCommonAccessibleText::getSelectionEnd();
516 : }
517 : // -----------------------------------------------------------------------------
518 0 : sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
519 : {
520 0 : SolarMutexGuard aSolarGuard;
521 0 : ::osl::MutexGuard aGuard( m_aMutex );
522 :
523 0 : if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
524 0 : throw IndexOutOfBoundsException();
525 :
526 0 : return sal_False;
527 : }
528 : // -----------------------------------------------------------------------------
529 0 : OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException)
530 : {
531 0 : SolarMutexGuard aSolarGuard;
532 0 : ::osl::MutexGuard aGuard( m_aMutex );
533 :
534 0 : return OCommonAccessibleText::getText();
535 : }
536 : // -----------------------------------------------------------------------------
537 0 : OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
538 : {
539 0 : SolarMutexGuard aSolarGuard;
540 0 : ::osl::MutexGuard aGuard( m_aMutex );
541 :
542 0 : return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
543 : }
544 : // -----------------------------------------------------------------------------
545 0 : ::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)
546 : {
547 0 : SolarMutexGuard aSolarGuard;
548 0 : ::osl::MutexGuard aGuard( m_aMutex );
549 :
550 0 : return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
551 : }
552 : // -----------------------------------------------------------------------------
553 0 : ::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)
554 : {
555 0 : SolarMutexGuard aSolarGuard;
556 0 : ::osl::MutexGuard aGuard( m_aMutex );
557 :
558 0 : return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
559 : }
560 : // -----------------------------------------------------------------------------
561 0 : ::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)
562 : {
563 0 : SolarMutexGuard aSolarGuard;
564 0 : ::osl::MutexGuard aGuard( m_aMutex );
565 :
566 0 : return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
567 : }
568 : // -----------------------------------------------------------------------------
569 0 : sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
570 : {
571 0 : SolarMutexGuard aSolarGuard;
572 0 : ::osl::MutexGuard aGuard( m_aMutex );
573 :
574 0 : checkIndex_Impl( nStartIndex, m_sEntryText );
575 0 : checkIndex_Impl( nEndIndex, m_sEntryText );
576 :
577 0 : sal_Bool bRet = sal_False;
578 0 : if ( m_pListBoxHelper )
579 : {
580 0 : Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard();
581 0 : if ( xClipboard.is() )
582 : {
583 0 : OUString sText( getTextRange( nStartIndex, nEndIndex ) );
584 0 : ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
585 :
586 0 : const sal_uInt32 nRef = Application::ReleaseSolarMutex();
587 0 : xClipboard->setContents( pDataObj, NULL );
588 0 : Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
589 0 : if( xFlushableClipboard.is() )
590 0 : xFlushableClipboard->flushClipboard();
591 0 : Application::AcquireSolarMutex( nRef );
592 :
593 0 : bRet = sal_True;
594 0 : }
595 : }
596 :
597 0 : return bRet;
598 : }
599 : // -----------------------------------------------------------------------------
600 : // XAccessibleEventBroadcaster
601 : // -----------------------------------------------------------------------------
602 0 : void SAL_CALL VCLXAccessibleListItem::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
603 : {
604 0 : if (xListener.is())
605 : {
606 0 : if (!m_nClientId)
607 0 : m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
608 0 : comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
609 : }
610 0 : }
611 : // -----------------------------------------------------------------------------
612 0 : void SAL_CALL VCLXAccessibleListItem::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
613 : {
614 0 : if ( xListener.is() && m_nClientId )
615 : {
616 0 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
617 0 : if ( !nListenerCount )
618 : {
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 0 : if ( m_nClientId )
624 : {
625 0 : comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId );
626 0 : m_nClientId = 0;
627 0 : comphelper::AccessibleEventNotifier::revokeClient( nId );
628 : }
629 : }
630 : }
631 0 : }
632 : // -----------------------------------------------------------------------------
633 :
634 :
635 :
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 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground (void)
640 : throw (::com::sun::star::uno::RuntimeException)
641 : {
642 0 : return COL_BLACK;
643 : }
644 :
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 0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground (void)
649 : throw (::com::sun::star::uno::RuntimeException)
650 : {
651 0 : return COL_WHITE;
652 : }
653 : // -----------------------------------------------------------------------------
654 :
655 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|