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