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/extended/accessibleiconchoicectrlentry.hxx>
30 : : #include <svtools/ivctrl.hxx>
31 : : #include <com/sun/star/awt/Point.hpp>
32 : : #include <com/sun/star/awt/Rectangle.hpp>
33 : : #include <com/sun/star/awt/Size.hpp>
34 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
35 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
36 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
37 : : #include <vcl/svapp.hxx>
38 : : #include <vcl/controllayout.hxx>
39 : : #include <toolkit/awt/vclxwindow.hxx>
40 : : #include <toolkit/helper/convert.hxx>
41 : : #include <unotools/accessiblestatesethelper.hxx>
42 : : #include <unotools/accessiblerelationsethelper.hxx>
43 : : #include <cppuhelper/typeprovider.hxx>
44 : : #include <comphelper/sequence.hxx>
45 : : #include <svtools/stringtransfer.hxx>
46 : : #include <comphelper/accessibleeventnotifier.hxx>
47 : :
48 : : #define ACCESSIBLE_ACTION_COUNT 1
49 : :
50 : : namespace
51 : : {
52 : 0 : void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
53 : : {
54 [ # # ][ # # ]: 0 : if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
55 : : // only three actions
56 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
57 : 0 : }
58 : : }
59 : :
60 : : //........................................................................
61 : : namespace accessibility
62 : : {
63 : :
64 : : // class AccessibleIconChoiceCtrlEntry -----------------------------------------------------
65 : :
66 : : using namespace ::com::sun::star::accessibility;
67 : : using namespace ::com::sun::star::uno;
68 : : using namespace ::com::sun::star::lang;
69 : : using namespace ::com::sun::star;
70 : :
71 : : // -----------------------------------------------------------------------------
72 : : // Ctor() and Dtor()
73 : : // -----------------------------------------------------------------------------
74 : 0 : AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
75 : : sal_uLong _nPos,
76 : : const Reference< XAccessible >& _xParent ) :
77 : :
78 : : AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ),
79 : :
80 : : m_pIconCtrl ( &_rIconCtrl ),
81 : : m_nIndex ( _nPos ),
82 : : m_nClientId ( 0 ),
83 [ # # ]: 0 : m_xParent ( _xParent )
84 : :
85 : : {
86 [ # # ]: 0 : osl_incrementInterlockedCount( &m_refCount );
87 : : {
88 [ # # ]: 0 : Reference< XComponent > xComp( m_xParent, UNO_QUERY );
89 [ # # ]: 0 : if ( xComp.is() )
90 [ # # ][ # # ]: 0 : xComp->addEventListener( this );
[ # # ]
91 : : }
92 [ # # ]: 0 : osl_decrementInterlockedCount( &m_refCount );
93 : 0 : }
94 : : // -----------------------------------------------------------------------------
95 : 0 : void AccessibleIconChoiceCtrlEntry::disposing( const EventObject& _rSource )
96 : : throw(RuntimeException)
97 : : {
98 [ # # ]: 0 : if ( _rSource.Source == m_xParent )
99 : : {
100 : 0 : dispose();
101 : : OSL_ENSURE( !m_xParent.is() && ( NULL == m_pIconCtrl ), "" );
102 : : }
103 : 0 : }
104 : : // -----------------------------------------------------------------------------
105 [ # # ][ # # ]: 0 : AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry()
106 : : {
107 [ # # ]: 0 : if ( IsAlive_Impl() )
108 : : {
109 : : // increment ref count to prevent double call of Dtor
110 [ # # ]: 0 : osl_incrementInterlockedCount( &m_refCount );
111 [ # # ]: 0 : dispose();
112 : : }
113 [ # # ]: 0 : }
114 : : // -----------------------------------------------------------------------------
115 : 0 : Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const
116 : : {
117 : 0 : Rectangle aRect;
118 : 0 : SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
119 [ # # ]: 0 : if ( pEntry )
120 : 0 : aRect = m_pIconCtrl->GetBoundingBox( pEntry );
121 : :
122 : 0 : return aRect;
123 : : }
124 : : // -----------------------------------------------------------------------------
125 : 0 : Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const
126 : : {
127 : 0 : Rectangle aRect;
128 : 0 : SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
129 [ # # ]: 0 : if ( pEntry )
130 : : {
131 [ # # ]: 0 : aRect = m_pIconCtrl->GetBoundingBox( pEntry );
132 : 0 : Point aTopLeft = aRect.TopLeft();
133 [ # # ]: 0 : aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( NULL ).TopLeft();
134 [ # # ][ # # ]: 0 : aRect = Rectangle( aTopLeft, aRect.GetSize() );
135 : : }
136 : :
137 : 0 : return aRect;
138 : : }
139 : : // -----------------------------------------------------------------------------
140 : 0 : sal_Bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const
141 : : {
142 [ # # ][ # # ]: 0 : return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl );
[ # # ]
143 : : }
144 : : // -----------------------------------------------------------------------------
145 : 0 : sal_Bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const
146 : : {
147 : 0 : sal_Bool bShowing = sal_False;
148 : : Reference< XAccessibleContext > m_xParentContext =
149 [ # # ][ # # ]: 0 : m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >();
[ # # ]
150 [ # # ]: 0 : if( m_xParentContext.is() )
151 : : {
152 [ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY );
153 [ # # ]: 0 : if( xParentComp.is() )
154 [ # # ][ # # ]: 0 : bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) );
[ # # ][ # # ]
[ # # ]
155 : : }
156 : :
157 : 0 : return bShowing;
158 : : }
159 : : // -----------------------------------------------------------------------------
160 : 0 : Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox() throw ( lang::DisposedException )
161 : : {
162 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
163 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
164 : :
165 [ # # ]: 0 : EnsureIsAlive();
166 [ # # ][ # # ]: 0 : return GetBoundingBox_Impl();
[ # # ]
167 : : }
168 : : // -----------------------------------------------------------------------------
169 : 0 : Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException )
170 : : {
171 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
172 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
173 : :
174 [ # # ]: 0 : EnsureIsAlive();
175 [ # # ][ # # ]: 0 : return GetBoundingBoxOnScreen_Impl();
[ # # ]
176 : : }
177 : : // -----------------------------------------------------------------------------
178 : 0 : void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const throw ( lang::DisposedException )
179 : : {
180 [ # # ]: 0 : if ( !IsAlive_Impl() )
181 [ # # ]: 0 : throw lang::DisposedException();
182 : 0 : }
183 : : // -----------------------------------------------------------------------------
184 : 0 : ::rtl::OUString AccessibleIconChoiceCtrlEntry::implGetText()
185 : : {
186 : 0 : ::rtl::OUString sRet;
187 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
188 [ # # ]: 0 : if ( pEntry )
189 [ # # ][ # # ]: 0 : sRet = pEntry->GetDisplayText();
[ # # ]
190 : 0 : return sRet;
191 : : }
192 : : // -----------------------------------------------------------------------------
193 : 0 : Locale AccessibleIconChoiceCtrlEntry::implGetLocale()
194 : : {
195 : 0 : Locale aLocale;
196 [ # # ][ # # ]: 0 : aLocale = Application::GetSettings().GetUILocale();
197 : :
198 : 0 : return aLocale;
199 : : }
200 : 0 : void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
201 : : {
202 : 0 : nStartIndex = 0;
203 : 0 : nEndIndex = 0;
204 : 0 : }
205 : : // -----------------------------------------------------------------------------
206 : : // XTypeProvider
207 : : // -----------------------------------------------------------------------------
208 : : // -----------------------------------------------------------------------------
209 : 0 : Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() throw (RuntimeException)
210 : : {
211 : : static ::cppu::OImplementationId* pId = NULL;
212 : :
213 [ # # ]: 0 : if ( !pId )
214 : : {
215 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
216 : :
217 [ # # ]: 0 : if ( !pId )
218 : : {
219 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
220 : 0 : pId = &aId;
221 [ # # ]: 0 : }
222 : : }
223 : 0 : return pId->getImplementationId();
224 : : }
225 : : // -----------------------------------------------------------------------------
226 : : // XComponent
227 : : // -----------------------------------------------------------------------------
228 : 0 : void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing()
229 : : {
230 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
231 : :
232 : : // Send a disposing to all listeners.
233 [ # # ]: 0 : if ( m_nClientId )
234 : : {
235 : 0 : sal_uInt32 nId = m_nClientId;
236 : 0 : m_nClientId = 0;
237 [ # # ][ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
238 : : }
239 : :
240 [ # # ]: 0 : Reference< XComponent > xComp( m_xParent, UNO_QUERY );
241 [ # # ]: 0 : if ( xComp.is() )
242 [ # # ][ # # ]: 0 : xComp->removeEventListener( this );
[ # # ]
243 : :
244 : 0 : m_pIconCtrl = NULL;
245 [ # # ][ # # ]: 0 : m_xParent = NULL;
246 : 0 : }
247 : : // -----------------------------------------------------------------------------
248 : : // XServiceInfo
249 : : // -----------------------------------------------------------------------------
250 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() throw(RuntimeException)
251 : : {
252 : 0 : return getImplementationName_Static();
253 : : }
254 : : // -----------------------------------------------------------------------------
255 : 0 : Sequence< ::rtl::OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() throw(RuntimeException)
256 : : {
257 : 0 : return getSupportedServiceNames_Static();
258 : : }
259 : : // -----------------------------------------------------------------------------
260 : 0 : sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
261 : : {
262 [ # # ]: 0 : Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
263 : 0 : const ::rtl::OUString* pSupported = aSupported.getConstArray();
264 : 0 : const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
265 [ # # ][ # # ]: 0 : for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
[ # # ]
266 : : ;
267 : :
268 [ # # ]: 0 : return pSupported != pEnd;
269 : : }
270 : : // -----------------------------------------------------------------------------
271 : : // XServiceInfo - static methods
272 : : // -----------------------------------------------------------------------------
273 : 0 : Sequence< ::rtl::OUString > AccessibleIconChoiceCtrlEntry::getSupportedServiceNames_Static(void) throw( RuntimeException )
274 : : {
275 : 0 : Sequence< ::rtl::OUString > aSupported(3);
276 [ # # ][ # # ]: 0 : aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") );
277 [ # # ][ # # ]: 0 : aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") );
278 [ # # ][ # # ]: 0 : aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleIconChoiceControlEntry") );
279 : 0 : return aSupported;
280 : : }
281 : : // -----------------------------------------------------------------------------
282 : 0 : ::rtl::OUString AccessibleIconChoiceCtrlEntry::getImplementationName_Static(void) throw( RuntimeException )
283 : : {
284 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry") );
285 : : }
286 : : // -----------------------------------------------------------------------------
287 : : // XAccessible
288 : : // -----------------------------------------------------------------------------
289 : 0 : Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext( ) throw (RuntimeException)
290 : : {
291 : 0 : EnsureIsAlive();
292 : 0 : return this;
293 : : }
294 : : // -----------------------------------------------------------------------------
295 : : // XAccessibleContext
296 : : // -----------------------------------------------------------------------------
297 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount( ) throw (RuntimeException)
298 : : {
299 : 0 : return 0; // no children
300 : : }
301 : : // -----------------------------------------------------------------------------
302 : 0 : Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException,RuntimeException)
303 : : {
304 [ # # ]: 0 : throw IndexOutOfBoundsException();
305 : : }
306 : : // -----------------------------------------------------------------------------
307 : 0 : Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent( ) throw (RuntimeException)
308 : : {
309 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
310 : :
311 [ # # ]: 0 : EnsureIsAlive();
312 [ # # ]: 0 : return m_xParent;
313 : : }
314 : : // -----------------------------------------------------------------------------
315 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent( ) throw (RuntimeException)
316 : : {
317 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
318 : :
319 [ # # ]: 0 : return m_nIndex;
320 : : }
321 : : // -----------------------------------------------------------------------------
322 : 0 : sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole( ) throw (RuntimeException)
323 : : {
324 : 0 : return AccessibleRole::LABEL;
325 : : }
326 : : // -----------------------------------------------------------------------------
327 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription( ) throw (RuntimeException)
328 : : {
329 : : // no description for every item
330 : 0 : return ::rtl::OUString();
331 : : }
332 : : // -----------------------------------------------------------------------------
333 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName( ) throw (RuntimeException)
334 : : {
335 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
336 : :
337 [ # # ]: 0 : EnsureIsAlive();
338 [ # # ][ # # ]: 0 : return implGetText();
339 : : }
340 : : // -----------------------------------------------------------------------------
341 : 0 : Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet( ) throw (RuntimeException)
342 : : {
343 [ # # ][ # # ]: 0 : return new utl::AccessibleRelationSetHelper;
344 : : }
345 : : // -----------------------------------------------------------------------------
346 : 0 : Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet( ) throw (RuntimeException)
347 : : {
348 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
349 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
350 : :
351 [ # # ]: 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
352 [ # # ][ # # ]: 0 : Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
353 : :
354 [ # # ]: 0 : if ( IsAlive_Impl() )
355 : : {
356 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
357 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
358 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::ENABLED );
359 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
360 [ # # ][ # # ]: 0 : if ( IsShowing_Impl() )
361 : : {
362 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
363 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
364 : : }
365 : :
366 [ # # ][ # # ]: 0 : if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) )
[ # # ][ # # ]
[ # # ]
367 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTED );
368 : : }
369 : : else
370 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
371 : :
372 [ # # ][ # # ]: 0 : return xStateSet;
373 : : }
374 : : // -----------------------------------------------------------------------------
375 : 0 : Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
376 : : {
377 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
378 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
379 : :
380 [ # # ][ # # ]: 0 : return implGetLocale();
[ # # ]
381 : : }
382 : : // -----------------------------------------------------------------------------
383 : : // XAccessibleComponent
384 : : // -----------------------------------------------------------------------------
385 : 0 : sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException)
386 : : {
387 [ # # ][ # # ]: 0 : return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
[ # # ][ # # ]
388 : : }
389 : : // -----------------------------------------------------------------------------
390 : 0 : Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
391 : : {
392 : 0 : return Reference< XAccessible >();
393 : : }
394 : : // -----------------------------------------------------------------------------
395 : 0 : awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) throw (RuntimeException)
396 : : {
397 [ # # ]: 0 : return AWTRectangle( GetBoundingBox() );
398 : : }
399 : : // -----------------------------------------------------------------------------
400 : 0 : awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) throw (RuntimeException)
401 : : {
402 : 0 : return AWTPoint( GetBoundingBox().TopLeft() );
403 : : }
404 : : // -----------------------------------------------------------------------------
405 : 0 : awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) throw (RuntimeException)
406 : : {
407 : 0 : return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
408 : : }
409 : : // -----------------------------------------------------------------------------
410 : 0 : awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) throw (RuntimeException)
411 : : {
412 [ # # ]: 0 : return AWTSize( GetBoundingBox().GetSize() );
413 : : }
414 : : // -----------------------------------------------------------------------------
415 : 0 : void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) throw (RuntimeException)
416 : : {
417 : : // do nothing, because no focus for each item
418 : 0 : }
419 : : // -----------------------------------------------------------------------------
420 : 0 : sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) throw (RuntimeException)
421 : : {
422 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
423 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
424 : :
425 : 0 : sal_Int32 nColor = 0;
426 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
427 [ # # ]: 0 : if ( xParent.is() )
428 : : {
429 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
430 [ # # ]: 0 : if ( xParentComp.is() )
431 [ # # ][ # # ]: 0 : nColor = xParentComp->getForeground();
432 : : }
433 : :
434 [ # # ][ # # ]: 0 : return nColor;
435 : : }
436 : : // -----------------------------------------------------------------------------
437 : 0 : sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground( ) throw (RuntimeException)
438 : : {
439 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
440 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
441 : :
442 : 0 : sal_Int32 nColor = 0;
443 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
444 [ # # ]: 0 : if ( xParent.is() )
445 : : {
446 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
447 [ # # ]: 0 : if ( xParentComp.is() )
448 [ # # ][ # # ]: 0 : nColor = xParentComp->getBackground();
449 : : }
450 : :
451 [ # # ][ # # ]: 0 : return nColor;
452 : : }
453 : : // -----------------------------------------------------------------------------
454 : : // XAccessibleText
455 : : // -----------------------------------------------------------------------------
456 : : // -----------------------------------------------------------------------------
457 : 0 : awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
458 : : {
459 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
460 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
461 : :
462 [ # # ][ # # ]: 0 : if ( ( 0 > _nIndex ) || ( getCharacterCount() <= _nIndex ) )
[ # # ][ # # ]
463 [ # # ]: 0 : throw IndexOutOfBoundsException();
464 : :
465 : 0 : awt::Rectangle aBounds( 0, 0, 0, 0 );
466 [ # # ]: 0 : if ( m_pIconCtrl )
467 : : {
468 [ # # ]: 0 : Rectangle aItemRect = GetBoundingBox_Impl();
469 [ # # ]: 0 : Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex );
470 [ # # ]: 0 : aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
471 [ # # ]: 0 : aBounds = AWTRectangle( aCharRect );
472 : : }
473 : :
474 [ # # ][ # # ]: 0 : return aBounds;
475 : : }
476 : : // -----------------------------------------------------------------------------
477 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
478 : : {
479 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
480 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
481 : :
482 : 0 : sal_Int32 nIndex = -1;
483 [ # # ]: 0 : if ( m_pIconCtrl )
484 : : {
485 [ # # ]: 0 : ::vcl::ControlLayoutData aLayoutData;
486 [ # # ]: 0 : Rectangle aItemRect = GetBoundingBox_Impl();
487 [ # # ]: 0 : m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect );
488 : 0 : Point aPnt( VCLPoint( aPoint ) );
489 : 0 : aPnt += aItemRect.TopLeft();
490 [ # # ]: 0 : nIndex = aLayoutData.GetIndexForPoint( aPnt );
491 : :
492 : 0 : long nLen = aLayoutData.m_aUnicodeBoundRects.size();
493 [ # # ]: 0 : for ( long i = 0; i < nLen; ++i )
494 : : {
495 [ # # ]: 0 : Rectangle aRect = aLayoutData.GetCharacterBounds(i);
496 [ # # ]: 0 : sal_Bool bInside = aRect.IsInside( aPnt );
497 : :
498 [ # # ]: 0 : if ( bInside )
499 : : break;
500 [ # # ]: 0 : }
501 : : }
502 : :
503 [ # # ][ # # ]: 0 : return nIndex;
504 : : }
505 : : // -----------------------------------------------------------------------------
506 : 0 : sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
507 : : {
508 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
509 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
510 : :
511 [ # # ][ # # ]: 0 : String sText = getText();
512 [ # # ]: 0 : if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex )
[ # # # # ]
[ # # ][ # # ]
513 : 0 : || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) )
514 [ # # ]: 0 : throw IndexOutOfBoundsException();
515 : :
516 : 0 : sal_Int32 nLen = nEndIndex - nStartIndex + 1;
517 [ # # ][ # # ]: 0 : ::svt::OStringTransfer::CopyString( sText.Copy( (sal_uInt16)nStartIndex, (sal_uInt16)nLen ), m_pIconCtrl );
[ # # ][ # # ]
518 : :
519 [ # # ][ # # ]: 0 : return sal_True;
[ # # ]
520 : : }
521 : : // -----------------------------------------------------------------------------
522 : : // XAccessibleEventBroadcaster
523 : : // -----------------------------------------------------------------------------
524 : 0 : void SAL_CALL AccessibleIconChoiceCtrlEntry::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
525 : : {
526 [ # # ]: 0 : if (xListener.is())
527 : : {
528 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
529 [ # # ]: 0 : if (!m_nClientId)
530 [ # # ]: 0 : m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
531 [ # # ][ # # ]: 0 : comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
532 : : }
533 : 0 : }
534 : : // -----------------------------------------------------------------------------
535 : 0 : void SAL_CALL AccessibleIconChoiceCtrlEntry::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
536 : : {
537 [ # # ]: 0 : if (xListener.is())
538 : : {
539 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
540 : :
541 [ # # ]: 0 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
542 [ # # ]: 0 : if ( !nListenerCount )
543 : : {
544 : : // no listeners anymore
545 : : // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
546 : : // and at least to us not firing any events anymore, in case somebody calls
547 : : // NotifyAccessibleEvent, again
548 : 0 : sal_Int32 nId = m_nClientId;
549 : 0 : m_nClientId = 0;
550 [ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClient( nId );
551 [ # # ]: 0 : }
552 : : }
553 : 0 : }
554 : :
555 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException)
556 : : {
557 : 0 : return -1;
558 : : }
559 : 0 : sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
560 : : {
561 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
562 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
563 [ # # ]: 0 : EnsureIsAlive();
564 : :
565 [ # # ][ # # ]: 0 : if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
[ # # ]
566 [ # # ]: 0 : throw IndexOutOfBoundsException();
567 : :
568 [ # # ][ # # ]: 0 : return sal_False;
569 : : }
570 : 0 : sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
571 : : {
572 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
573 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
574 [ # # ]: 0 : EnsureIsAlive();
575 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getCharacter( nIndex );
[ # # ]
576 : : }
577 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
578 : : {
579 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
580 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
581 [ # # ]: 0 : EnsureIsAlive();
582 : :
583 [ # # ]: 0 : ::rtl::OUString sText( implGetText() );
584 : :
585 [ # # ][ # # ]: 0 : if ( !implIsValidIndex( nIndex, sText.getLength() ) )
586 [ # # ]: 0 : throw IndexOutOfBoundsException();
587 : :
588 [ # # ][ # # ]: 0 : return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
[ # # ]
589 : : }
590 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException)
591 : : {
592 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
593 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
594 [ # # ]: 0 : EnsureIsAlive();
595 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getCharacterCount( );
[ # # ]
596 : : }
597 : :
598 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException)
599 : : {
600 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
601 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
602 [ # # ]: 0 : EnsureIsAlive();
603 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectedText( );
[ # # ]
604 : : }
605 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException)
606 : : {
607 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
608 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
609 [ # # ]: 0 : EnsureIsAlive();
610 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionStart( );
[ # # ]
611 : : }
612 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException)
613 : : {
614 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
615 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
616 [ # # ]: 0 : EnsureIsAlive();
617 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionEnd( );
[ # # ]
618 : : }
619 : 0 : sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
620 : : {
621 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
622 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
623 [ # # ]: 0 : EnsureIsAlive();
624 : :
625 [ # # ][ # # ]: 0 : if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
[ # # ]
626 [ # # ]: 0 : throw IndexOutOfBoundsException();
627 : :
628 [ # # ][ # # ]: 0 : return sal_False;
629 : : }
630 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText( ) throw (::com::sun::star::uno::RuntimeException)
631 : : {
632 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
633 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
634 [ # # ]: 0 : EnsureIsAlive();
635 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getText( );
[ # # ]
636 : : }
637 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
638 : : {
639 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
640 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
641 [ # # ]: 0 : EnsureIsAlive();
642 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
[ # # ]
643 : : }
644 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
645 : : {
646 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
647 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
648 [ # # ]: 0 : EnsureIsAlive();
649 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
[ # # ]
650 : : }
651 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
652 : : {
653 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
654 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
655 [ # # ]: 0 : EnsureIsAlive();
656 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
[ # # ]
657 : : }
658 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
659 : : {
660 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
661 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
662 [ # # ]: 0 : EnsureIsAlive();
663 : :
664 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
[ # # ]
665 : : }
666 : :
667 : : // -----------------------------------------------------------------------------
668 : : // XAccessibleAction
669 : : // -----------------------------------------------------------------------------
670 : 0 : sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount( ) throw (RuntimeException)
671 : : {
672 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
673 : :
674 : : // three actions supported
675 [ # # ]: 0 : return ACCESSIBLE_ACTION_COUNT;
676 : : }
677 : : // -----------------------------------------------------------------------------
678 : 0 : sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
679 : : {
680 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
681 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
682 : :
683 : 0 : sal_Bool bRet = sal_False;
684 [ # # ]: 0 : checkActionIndex_Impl( nIndex );
685 [ # # ]: 0 : EnsureIsAlive();
686 : :
687 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
688 [ # # ][ # # ]: 0 : if ( pEntry && !pEntry->IsSelected() )
[ # # ]
689 : : {
690 [ # # ]: 0 : m_pIconCtrl->SetNoSelection();
691 [ # # ]: 0 : m_pIconCtrl->SetCursor( pEntry );
692 : 0 : bRet = sal_True;
693 : : }
694 : :
695 [ # # ][ # # ]: 0 : return bRet;
696 : : }
697 : : // -----------------------------------------------------------------------------
698 : 0 : ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
699 : : {
700 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
701 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
702 : :
703 [ # # ]: 0 : checkActionIndex_Impl( nIndex );
704 [ # # ]: 0 : EnsureIsAlive();
705 : :
706 [ # # ][ # # ]: 0 : static const ::rtl::OUString sActionDesc( RTL_CONSTASCII_USTRINGPARAM( "Select" ) );
[ # # ][ # # ]
707 [ # # ][ # # ]: 0 : return sActionDesc;
708 : : }
709 : : // -----------------------------------------------------------------------------
710 : 0 : Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
711 : : {
712 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
713 : :
714 : 0 : Reference< XAccessibleKeyBinding > xRet;
715 [ # # ]: 0 : checkActionIndex_Impl( nIndex );
716 : : // ... which key?
717 [ # # ]: 0 : return xRet;
718 : : }
719 : : //........................................................................
720 : : }// namespace accessibility
721 : : //........................................................................
722 : :
723 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|