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