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/accessibletabbarpagelist.hxx>
30 : : #include <svtools/tabbar.hxx>
31 : : #include <accessibility/extended/accessibletabbarpage.hxx>
32 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
33 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
35 : : #include <unotools/accessiblestatesethelper.hxx>
36 : : #include <unotools/accessiblerelationsethelper.hxx>
37 : : #include <vcl/svapp.hxx>
38 : : #include <toolkit/helper/convert.hxx>
39 : :
40 : :
41 : : //.........................................................................
42 : : namespace accessibility
43 : : {
44 : : //.........................................................................
45 : :
46 : : using namespace ::com::sun::star::accessibility;
47 : : using namespace ::com::sun::star::uno;
48 : : using namespace ::com::sun::star::lang;
49 : : using namespace ::com::sun::star;
50 : : using namespace ::comphelper;
51 : :
52 : : // -----------------------------------------------------------------------------
53 : : // class AccessibleTabBarPageList
54 : : // -----------------------------------------------------------------------------
55 : :
56 : 0 : AccessibleTabBarPageList::AccessibleTabBarPageList( TabBar* pTabBar, sal_Int32 nIndexInParent )
57 : : :AccessibleTabBarBase( pTabBar )
58 [ # # ]: 0 : ,m_nIndexInParent( nIndexInParent )
59 : : {
60 [ # # ]: 0 : if ( m_pTabBar )
61 [ # # ][ # # ]: 0 : m_aAccessibleChildren.assign( m_pTabBar->GetPageCount(), Reference< XAccessible >() );
62 : 0 : }
63 : :
64 : : // -----------------------------------------------------------------------------
65 : :
66 : 0 : AccessibleTabBarPageList::~AccessibleTabBarPageList()
67 : : {
68 [ # # ]: 0 : }
69 : :
70 : : // -----------------------------------------------------------------------------
71 : :
72 : 0 : void AccessibleTabBarPageList::UpdateEnabled( sal_Int32 i, sal_Bool bEnabled )
73 : : {
74 [ # # ][ # # ]: 0 : if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
[ # # ]
75 : : {
76 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
77 [ # # ]: 0 : if ( xChild.is() )
78 : : {
79 [ # # ][ # # ]: 0 : AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
80 [ # # ]: 0 : if ( pAccessibleTabBarPage )
81 [ # # ]: 0 : pAccessibleTabBarPage->SetEnabled( bEnabled );
82 : 0 : }
83 : : }
84 : 0 : }
85 : :
86 : : // -----------------------------------------------------------------------------
87 : :
88 : 0 : void AccessibleTabBarPageList::UpdateShowing( sal_Bool bShowing )
89 : : {
90 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
91 : : {
92 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
93 [ # # ]: 0 : if ( xChild.is() )
94 : : {
95 [ # # ][ # # ]: 0 : AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
96 [ # # ]: 0 : if ( pAccessibleTabBarPage )
97 [ # # ]: 0 : pAccessibleTabBarPage->SetShowing( bShowing );
98 : : }
99 : 0 : }
100 : 0 : }
101 : :
102 : : // -----------------------------------------------------------------------------
103 : :
104 : 0 : void AccessibleTabBarPageList::UpdateSelected( sal_Int32 i, sal_Bool bSelected )
105 : : {
106 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
107 : :
108 [ # # ][ # # ]: 0 : if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
[ # # ]
109 : : {
110 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
111 [ # # ]: 0 : if ( xChild.is() )
112 : : {
113 [ # # ][ # # ]: 0 : AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
114 [ # # ]: 0 : if ( pAccessibleTabBarPage )
115 [ # # ]: 0 : pAccessibleTabBarPage->SetSelected( bSelected );
116 : 0 : }
117 : : }
118 : 0 : }
119 : :
120 : : // -----------------------------------------------------------------------------
121 : :
122 : 0 : void AccessibleTabBarPageList::UpdatePageText( sal_Int32 i )
123 : : {
124 [ # # ][ # # ]: 0 : if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
[ # # ]
125 : : {
126 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
127 [ # # ]: 0 : if ( xChild.is() )
128 : : {
129 [ # # ][ # # ]: 0 : AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
130 [ # # ]: 0 : if ( pAccessibleTabBarPage )
131 : : {
132 [ # # ]: 0 : if ( m_pTabBar )
133 : : {
134 [ # # ][ # # ]: 0 : ::rtl::OUString sPageText = m_pTabBar->GetPageText( m_pTabBar->GetPageId( (sal_uInt16)i ) );
[ # # ][ # # ]
135 [ # # ]: 0 : pAccessibleTabBarPage->SetPageText( sPageText );
136 : : }
137 : : }
138 : 0 : }
139 : : }
140 : 0 : }
141 : :
142 : : // -----------------------------------------------------------------------------
143 : :
144 : 0 : void AccessibleTabBarPageList::InsertChild( sal_Int32 i )
145 : : {
146 [ # # ][ # # ]: 0 : if ( i >= 0 && i <= (sal_Int32)m_aAccessibleChildren.size() )
[ # # ]
147 : : {
148 : : // insert entry in child list
149 [ # # ][ # # ]: 0 : m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
150 : :
151 : : // send accessible child event
152 [ # # ]: 0 : Reference< XAccessible > xChild( getAccessibleChild( i ) );
153 [ # # ]: 0 : if ( xChild.is() )
154 : : {
155 : 0 : Any aOldValue, aNewValue;
156 [ # # ]: 0 : aNewValue <<= xChild;
157 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
158 : 0 : }
159 : : }
160 : 0 : }
161 : :
162 : : // -----------------------------------------------------------------------------
163 : :
164 : 0 : void AccessibleTabBarPageList::RemoveChild( sal_Int32 i )
165 : : {
166 [ # # ][ # # ]: 0 : if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
[ # # ]
167 : : {
168 : : // get the accessible of the removed page
169 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
170 : :
171 : : // remove entry in child list
172 [ # # ][ # # ]: 0 : m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
173 : :
174 : : // send accessible child event
175 [ # # ]: 0 : if ( xChild.is() )
176 : : {
177 : 0 : Any aOldValue, aNewValue;
178 [ # # ]: 0 : aOldValue <<= xChild;
179 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
180 : :
181 [ # # ]: 0 : Reference< XComponent > xComponent( xChild, UNO_QUERY );
182 [ # # ]: 0 : if ( xComponent.is() )
183 [ # # ][ # # ]: 0 : xComponent->dispose();
184 : 0 : }
185 : : }
186 : 0 : }
187 : :
188 : : // -----------------------------------------------------------------------------
189 : :
190 : 0 : void AccessibleTabBarPageList::MoveChild( sal_Int32 i, sal_Int32 j )
191 : : {
192 [ # # ][ # # ]: 0 : if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() &&
[ # # # # ]
[ # # ]
193 : 0 : j >= 0 && j <= (sal_Int32)m_aAccessibleChildren.size() )
194 : : {
195 [ # # ]: 0 : if ( i < j )
196 : 0 : --j;
197 : :
198 : : // get the accessible of the moved page
199 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
200 : :
201 : : // remove entry in child list at old position
202 [ # # ][ # # ]: 0 : m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
203 : :
204 : : // insert entry in child list at new position
205 [ # # ][ # # ]: 0 : m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + j, xChild );
206 : : }
207 : 0 : }
208 : :
209 : : // -----------------------------------------------------------------------------
210 : :
211 : 0 : void AccessibleTabBarPageList::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
212 : : {
213 [ # # # # : 0 : switch ( rVclWindowEvent.GetId() )
# # # # #
# # # #
# ]
214 : : {
215 : : case VCLEVENT_WINDOW_ENABLED:
216 : : {
217 : 0 : Any aNewValue;
218 [ # # ]: 0 : aNewValue <<= AccessibleStateType::SENSITIVE;
219 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), aNewValue );
220 [ # # ]: 0 : aNewValue <<= AccessibleStateType::ENABLED;
221 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), aNewValue );
222 : : }
223 : 0 : break;
224 : : case VCLEVENT_WINDOW_DISABLED:
225 : : {
226 : 0 : Any aOldValue;
227 [ # # ]: 0 : aOldValue <<= AccessibleStateType::ENABLED;
228 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, Any() );
229 [ # # ]: 0 : aOldValue <<= AccessibleStateType::SENSITIVE;
230 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, Any() );
231 : : }
232 : 0 : break;
233 : : case VCLEVENT_WINDOW_SHOW:
234 : : {
235 : 0 : Any aOldValue, aNewValue;
236 [ # # ]: 0 : aNewValue <<= AccessibleStateType::SHOWING;
237 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
238 [ # # ]: 0 : UpdateShowing( sal_True );
239 : : }
240 : 0 : break;
241 : : case VCLEVENT_WINDOW_HIDE:
242 : : {
243 : 0 : Any aOldValue, aNewValue;
244 [ # # ]: 0 : aOldValue <<= AccessibleStateType::SHOWING;
245 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
246 [ # # ]: 0 : UpdateShowing( sal_False );
247 : : }
248 : 0 : break;
249 : : case VCLEVENT_TABBAR_PAGEENABLED:
250 : : {
251 [ # # ]: 0 : if ( m_pTabBar )
252 : : {
253 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
254 : 0 : sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
255 : 0 : UpdateEnabled( nPagePos, sal_True );
256 : : }
257 : : }
258 : 0 : break;
259 : : case VCLEVENT_TABBAR_PAGEDISABLED:
260 : : {
261 [ # # ]: 0 : if ( m_pTabBar )
262 : : {
263 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
264 : 0 : sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
265 : 0 : UpdateEnabled( nPagePos, sal_False );
266 : : }
267 : : }
268 : 0 : break;
269 : : case VCLEVENT_TABBAR_PAGESELECTED:
270 : : {
271 : : // do nothing
272 : : }
273 : 0 : break;
274 : : case VCLEVENT_TABBAR_PAGEACTIVATED:
275 : : {
276 [ # # ]: 0 : if ( m_pTabBar )
277 : : {
278 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
279 : 0 : sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
280 : 0 : UpdateSelected( nPagePos, sal_True );
281 : : }
282 : : }
283 : 0 : break;
284 : : case VCLEVENT_TABBAR_PAGEDEACTIVATED:
285 : : {
286 [ # # ]: 0 : if ( m_pTabBar )
287 : : {
288 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
289 : 0 : sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
290 : 0 : UpdateSelected( nPagePos, sal_False );
291 : : }
292 : : }
293 : 0 : break;
294 : : case VCLEVENT_TABBAR_PAGEINSERTED:
295 : : {
296 [ # # ]: 0 : if ( m_pTabBar )
297 : : {
298 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
299 : 0 : sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
300 : 0 : InsertChild( nPagePos );
301 : : }
302 : : }
303 : 0 : break;
304 : : case VCLEVENT_TABBAR_PAGEREMOVED:
305 : : {
306 [ # # ]: 0 : if ( m_pTabBar )
307 : : {
308 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
309 : :
310 [ # # ]: 0 : if ( nPageId == TabBar::PAGE_NOT_FOUND )
311 : : {
312 [ # # ]: 0 : for ( sal_Int32 i = m_aAccessibleChildren.size() - 1; i >= 0; --i )
313 : 0 : RemoveChild( i );
314 : : }
315 : : else
316 : : {
317 [ # # ]: 0 : for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
318 : : {
319 [ # # ]: 0 : Reference< XAccessible > xChild( getAccessibleChild( i ) );
320 [ # # ]: 0 : if ( xChild.is() )
321 : : {
322 [ # # ][ # # ]: 0 : AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
323 [ # # ][ # # ]: 0 : if ( pAccessibleTabBarPage && pAccessibleTabBarPage->GetPageId() == nPageId )
[ # # ]
324 : : {
325 [ # # ]: 0 : RemoveChild( i );
326 : : break;
327 : : }
328 : : }
329 [ # # ]: 0 : }
330 : : }
331 : : }
332 : : }
333 : 0 : break;
334 : : case VCLEVENT_TABBAR_PAGEMOVED:
335 : : {
336 : 0 : Pair* pPair = (Pair*) rVclWindowEvent.GetData();
337 [ # # ]: 0 : if ( pPair )
338 : 0 : MoveChild( pPair->A(), pPair->B() );
339 : : }
340 : 0 : break;
341 : : case VCLEVENT_TABBAR_PAGETEXTCHANGED:
342 : : {
343 : 0 : sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
344 : 0 : sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
345 : 0 : UpdatePageText( nPagePos );
346 : : }
347 : 0 : break;
348 : : default:
349 : : {
350 : 0 : AccessibleTabBarBase::ProcessWindowEvent( rVclWindowEvent );
351 : : }
352 : 0 : break;
353 : : }
354 : 0 : }
355 : :
356 : : // -----------------------------------------------------------------------------
357 : :
358 : 0 : void AccessibleTabBarPageList::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
359 : : {
360 [ # # ]: 0 : if ( m_pTabBar )
361 : : {
362 [ # # ]: 0 : if ( m_pTabBar->IsEnabled() )
363 : : {
364 : 0 : rStateSet.AddState( AccessibleStateType::ENABLED );
365 : 0 : rStateSet.AddState( AccessibleStateType::SENSITIVE );
366 : : }
367 : :
368 : 0 : rStateSet.AddState( AccessibleStateType::VISIBLE );
369 : :
370 [ # # ]: 0 : if ( m_pTabBar->IsVisible() )
371 : 0 : rStateSet.AddState( AccessibleStateType::SHOWING );
372 : : }
373 : 0 : }
374 : :
375 : : // -----------------------------------------------------------------------------
376 : : // OCommonAccessibleComponent
377 : : // -----------------------------------------------------------------------------
378 : :
379 : 0 : awt::Rectangle AccessibleTabBarPageList::implGetBounds() throw (RuntimeException)
380 : : {
381 : 0 : awt::Rectangle aBounds;
382 [ # # ]: 0 : if ( m_pTabBar )
383 [ # # ]: 0 : aBounds = AWTRectangle( m_pTabBar->GetPageArea() );
384 : :
385 : 0 : return aBounds;
386 : : }
387 : :
388 : : // -----------------------------------------------------------------------------
389 : : // XInterface
390 : : // -----------------------------------------------------------------------------
391 : :
392 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabBarPageList, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPageList_BASE )
393 : :
394 : : // -----------------------------------------------------------------------------
395 : : // XTypeProvider
396 : : // -----------------------------------------------------------------------------
397 : :
398 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabBarPageList, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPageList_BASE )
[ # # ]
399 : :
400 : : // -----------------------------------------------------------------------------
401 : : // XComponent
402 : : // -----------------------------------------------------------------------------
403 : :
404 : 0 : void AccessibleTabBarPageList::disposing()
405 : : {
406 : 0 : AccessibleTabBarBase::disposing();
407 : :
408 : : // dispose all children
409 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
410 : : {
411 [ # # ]: 0 : Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
412 [ # # ]: 0 : if ( xComponent.is() )
413 [ # # ][ # # ]: 0 : xComponent->dispose();
414 : 0 : }
415 : 0 : m_aAccessibleChildren.clear();
416 : 0 : }
417 : :
418 : : // -----------------------------------------------------------------------------
419 : : // XServiceInfo
420 : : // -----------------------------------------------------------------------------
421 : :
422 : 0 : ::rtl::OUString AccessibleTabBarPageList::getImplementationName() throw (RuntimeException)
423 : : {
424 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleTabBarPageList" ));
425 : : }
426 : :
427 : : // -----------------------------------------------------------------------------
428 : :
429 : 0 : sal_Bool AccessibleTabBarPageList::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
430 : : {
431 [ # # ]: 0 : Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
432 : 0 : const ::rtl::OUString* pNames = aNames.getConstArray();
433 : 0 : const ::rtl::OUString* pEnd = pNames + aNames.getLength();
434 [ # # ][ # # ]: 0 : for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
[ # # ]
435 : : ;
436 : :
437 [ # # ]: 0 : return pNames != pEnd;
438 : : }
439 : :
440 : : // -----------------------------------------------------------------------------
441 : :
442 : 0 : Sequence< ::rtl::OUString > AccessibleTabBarPageList::getSupportedServiceNames() throw (RuntimeException)
443 : : {
444 : 0 : Sequence< ::rtl::OUString > aNames(1);
445 [ # # ][ # # ]: 0 : aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.AccessibleTabBarPageList" ));
446 : 0 : return aNames;
447 : : }
448 : :
449 : : // -----------------------------------------------------------------------------
450 : : // XAccessible
451 : : // -----------------------------------------------------------------------------
452 : :
453 : 0 : Reference< XAccessibleContext > AccessibleTabBarPageList::getAccessibleContext( ) throw (RuntimeException)
454 : : {
455 [ # # ]: 0 : OExternalLockGuard aGuard( this );
456 : :
457 [ # # ][ # # ]: 0 : return this;
458 : : }
459 : :
460 : : // -----------------------------------------------------------------------------
461 : : // XAccessibleContext
462 : : // -----------------------------------------------------------------------------
463 : :
464 : 0 : sal_Int32 AccessibleTabBarPageList::getAccessibleChildCount() throw (RuntimeException)
465 : : {
466 [ # # ]: 0 : OExternalLockGuard aGuard( this );
467 : :
468 [ # # ]: 0 : return m_aAccessibleChildren.size();
469 : : }
470 : :
471 : : // -----------------------------------------------------------------------------
472 : :
473 : 0 : Reference< XAccessible > AccessibleTabBarPageList::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
474 : : {
475 [ # # ]: 0 : OExternalLockGuard aGuard( this );
476 : :
477 [ # # ][ # # ]: 0 : if ( i < 0 || i >= getAccessibleChildCount() )
[ # # ][ # # ]
478 [ # # ]: 0 : throw IndexOutOfBoundsException();
479 : :
480 : 0 : Reference< XAccessible > xChild = m_aAccessibleChildren[i];
481 [ # # ]: 0 : if ( !xChild.is() )
482 : : {
483 [ # # ]: 0 : if ( m_pTabBar )
484 : : {
485 [ # # ]: 0 : sal_uInt16 nPageId = m_pTabBar->GetPageId( (sal_uInt16)i );
486 : :
487 [ # # ][ # # ]: 0 : xChild = new AccessibleTabBarPage( m_pTabBar, nPageId, this );
[ # # ][ # # ]
488 : :
489 : : // insert into child list
490 [ # # ]: 0 : m_aAccessibleChildren[i] = xChild;
491 : : }
492 : : }
493 : :
494 [ # # ]: 0 : return xChild;
495 : : }
496 : :
497 : : // -----------------------------------------------------------------------------
498 : :
499 : 0 : Reference< XAccessible > AccessibleTabBarPageList::getAccessibleParent( ) throw (RuntimeException)
500 : : {
501 [ # # ]: 0 : OExternalLockGuard aGuard( this );
502 : :
503 : 0 : Reference< XAccessible > xParent;
504 [ # # ]: 0 : if ( m_pTabBar )
505 [ # # ][ # # ]: 0 : xParent = m_pTabBar->GetAccessible();
506 : :
507 [ # # ]: 0 : return xParent;
508 : : }
509 : :
510 : : // -----------------------------------------------------------------------------
511 : :
512 : 0 : sal_Int32 AccessibleTabBarPageList::getAccessibleIndexInParent( ) throw (RuntimeException)
513 : : {
514 [ # # ]: 0 : OExternalLockGuard aGuard( this );
515 : :
516 [ # # ]: 0 : return m_nIndexInParent;
517 : : }
518 : :
519 : : // -----------------------------------------------------------------------------
520 : :
521 : 0 : sal_Int16 AccessibleTabBarPageList::getAccessibleRole( ) throw (RuntimeException)
522 : : {
523 [ # # ]: 0 : OExternalLockGuard aGuard( this );
524 : :
525 [ # # ]: 0 : return AccessibleRole::PAGE_TAB_LIST;
526 : : }
527 : :
528 : : // -----------------------------------------------------------------------------
529 : :
530 : 0 : ::rtl::OUString AccessibleTabBarPageList::getAccessibleDescription( ) throw (RuntimeException)
531 : : {
532 [ # # ]: 0 : OExternalLockGuard aGuard( this );
533 : :
534 [ # # ]: 0 : return ::rtl::OUString();
535 : : }
536 : :
537 : : // -----------------------------------------------------------------------------
538 : :
539 : 0 : ::rtl::OUString AccessibleTabBarPageList::getAccessibleName( ) throw (RuntimeException)
540 : : {
541 [ # # ]: 0 : OExternalLockGuard aGuard( this );
542 : :
543 [ # # ]: 0 : return ::rtl::OUString();
544 : : }
545 : :
546 : : // -----------------------------------------------------------------------------
547 : :
548 : 0 : Reference< XAccessibleRelationSet > AccessibleTabBarPageList::getAccessibleRelationSet( ) throw (RuntimeException)
549 : : {
550 [ # # ]: 0 : OExternalLockGuard aGuard( this );
551 : :
552 [ # # ]: 0 : utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
553 [ # # ][ # # ]: 0 : Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
554 [ # # ]: 0 : return xSet;
555 : : }
556 : :
557 : : // -----------------------------------------------------------------------------
558 : :
559 : 0 : Reference< XAccessibleStateSet > AccessibleTabBarPageList::getAccessibleStateSet( ) throw (RuntimeException)
560 : : {
561 [ # # ]: 0 : OExternalLockGuard aGuard( this );
562 : :
563 [ # # ]: 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
564 [ # # ][ # # ]: 0 : Reference< XAccessibleStateSet > xSet = pStateSetHelper;
565 : :
566 [ # # ][ # # ]: 0 : if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
567 : : {
568 [ # # ]: 0 : FillAccessibleStateSet( *pStateSetHelper );
569 : : }
570 : : else
571 : : {
572 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
573 : : }
574 : :
575 [ # # ]: 0 : return xSet;
576 : : }
577 : :
578 : : // -----------------------------------------------------------------------------
579 : :
580 : 0 : Locale AccessibleTabBarPageList::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
581 : : {
582 [ # # ]: 0 : OExternalLockGuard aGuard( this );
583 : :
584 [ # # ][ # # ]: 0 : return Application::GetSettings().GetLocale();
[ # # ]
585 : : }
586 : :
587 : : // -----------------------------------------------------------------------------
588 : : // XAccessibleComponent
589 : : // -----------------------------------------------------------------------------
590 : :
591 : 0 : Reference< XAccessible > AccessibleTabBarPageList::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
592 : : {
593 [ # # ]: 0 : OExternalLockGuard aGuard( this );
594 : :
595 : 0 : Reference< XAccessible > xChild;
596 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
597 : : {
598 [ # # ]: 0 : Reference< XAccessible > xAcc = getAccessibleChild( i );
599 [ # # ]: 0 : if ( xAcc.is() )
600 : : {
601 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
[ # # ]
602 [ # # ]: 0 : if ( xComp.is() )
603 : : {
604 [ # # ][ # # ]: 0 : Rectangle aRect = VCLRectangle( xComp->getBounds() );
[ # # ]
605 : 0 : Point aPos = VCLPoint( rPoint );
606 [ # # ][ # # ]: 0 : if ( aRect.IsInside( aPos ) )
607 : : {
608 [ # # ]: 0 : xChild = xAcc;
609 : : break;
610 : : }
611 [ # # ]: 0 : }
612 : : }
613 [ # # ]: 0 : }
614 : :
615 [ # # ]: 0 : return xChild;
616 : : }
617 : :
618 : : // -----------------------------------------------------------------------------
619 : :
620 : 0 : void AccessibleTabBarPageList::grabFocus( ) throw (RuntimeException)
621 : : {
622 : : // no focus
623 : 0 : }
624 : :
625 : : // -----------------------------------------------------------------------------
626 : :
627 : 0 : sal_Int32 AccessibleTabBarPageList::getForeground( ) throw (RuntimeException)
628 : : {
629 [ # # ]: 0 : OExternalLockGuard aGuard( this );
630 : :
631 : 0 : sal_Int32 nColor = 0;
632 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
633 [ # # ]: 0 : if ( xParent.is() )
634 : : {
635 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
636 [ # # ]: 0 : if ( xParentComp.is() )
637 [ # # ][ # # ]: 0 : nColor = xParentComp->getForeground();
638 : : }
639 : :
640 [ # # ]: 0 : return nColor;
641 : : }
642 : :
643 : : // -----------------------------------------------------------------------------
644 : :
645 : 0 : sal_Int32 AccessibleTabBarPageList::getBackground( ) throw (RuntimeException)
646 : : {
647 [ # # ]: 0 : OExternalLockGuard aGuard( this );
648 : :
649 : 0 : sal_Int32 nColor = 0;
650 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
651 [ # # ]: 0 : if ( xParent.is() )
652 : : {
653 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
654 [ # # ]: 0 : if ( xParentComp.is() )
655 [ # # ][ # # ]: 0 : nColor = xParentComp->getBackground();
656 : : }
657 : :
658 [ # # ]: 0 : return nColor;
659 : : }
660 : :
661 : : // -----------------------------------------------------------------------------
662 : : // XAccessibleExtendedComponent
663 : : // -----------------------------------------------------------------------------
664 : :
665 : 0 : Reference< awt::XFont > AccessibleTabBarPageList::getFont( ) throw (RuntimeException)
666 : : {
667 [ # # ]: 0 : OExternalLockGuard aGuard( this );
668 : :
669 : 0 : Reference< awt::XFont > xFont;
670 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
671 [ # # ]: 0 : if ( xParent.is() )
672 : : {
673 [ # # ][ # # ]: 0 : Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
674 [ # # ]: 0 : if ( xParentComp.is() )
675 [ # # ][ # # ]: 0 : xFont = xParentComp->getFont();
[ # # ]
676 : : }
677 : :
678 [ # # ]: 0 : return xFont;
679 : : }
680 : :
681 : : // -----------------------------------------------------------------------------
682 : :
683 : 0 : ::rtl::OUString AccessibleTabBarPageList::getTitledBorderText( ) throw (RuntimeException)
684 : : {
685 [ # # ]: 0 : OExternalLockGuard aGuard( this );
686 : :
687 [ # # ]: 0 : return ::rtl::OUString();
688 : : }
689 : :
690 : : // -----------------------------------------------------------------------------
691 : :
692 : 0 : ::rtl::OUString AccessibleTabBarPageList::getToolTipText( ) throw (RuntimeException)
693 : : {
694 [ # # ]: 0 : OExternalLockGuard aGuard( this );
695 : :
696 [ # # ]: 0 : return ::rtl::OUString();
697 : : }
698 : :
699 : : // -----------------------------------------------------------------------------
700 : : // XAccessibleSelection
701 : : // -----------------------------------------------------------------------------
702 : :
703 : 0 : void AccessibleTabBarPageList::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
704 : : {
705 [ # # ]: 0 : OExternalLockGuard aGuard( this );
706 : :
707 [ # # ][ # # ]: 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
[ # # ][ # # ]
708 [ # # ]: 0 : throw IndexOutOfBoundsException();
709 : :
710 [ # # ]: 0 : if ( m_pTabBar )
711 : : {
712 [ # # ][ # # ]: 0 : m_pTabBar->SetCurPageId( m_pTabBar->GetPageId( (sal_uInt16)nChildIndex ) );
713 [ # # ]: 0 : m_pTabBar->Update();
714 [ # # ]: 0 : m_pTabBar->ActivatePage();
715 [ # # ]: 0 : m_pTabBar->Select();
716 [ # # ]: 0 : }
717 : 0 : }
718 : :
719 : : // -----------------------------------------------------------------------------
720 : :
721 : 0 : sal_Bool AccessibleTabBarPageList::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
722 : : {
723 [ # # ]: 0 : OExternalLockGuard aGuard( this );
724 : :
725 [ # # ][ # # ]: 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
[ # # ][ # # ]
726 [ # # ]: 0 : throw IndexOutOfBoundsException();
727 : :
728 : 0 : sal_Bool bSelected = sal_False;
729 [ # # ][ # # ]: 0 : if ( m_pTabBar && m_pTabBar->GetCurPageId() == m_pTabBar->GetPageId( (sal_uInt16)nChildIndex ) )
[ # # ][ # # ]
730 : 0 : bSelected = sal_True;
731 : :
732 [ # # ]: 0 : return bSelected;
733 : : }
734 : :
735 : : // -----------------------------------------------------------------------------
736 : :
737 : 0 : void AccessibleTabBarPageList::clearAccessibleSelection( ) throw (RuntimeException)
738 : : {
739 : : // This method makes no sense in a TabBar, and so does nothing.
740 : 0 : }
741 : :
742 : : // -----------------------------------------------------------------------------
743 : :
744 : 0 : void AccessibleTabBarPageList::selectAllAccessibleChildren( ) throw (RuntimeException)
745 : : {
746 [ # # ]: 0 : OExternalLockGuard aGuard( this );
747 : :
748 [ # # ][ # # ]: 0 : selectAccessibleChild( 0 );
749 : 0 : }
750 : :
751 : : // -----------------------------------------------------------------------------
752 : :
753 : 0 : sal_Int32 AccessibleTabBarPageList::getSelectedAccessibleChildCount( ) throw (RuntimeException)
754 : : {
755 [ # # ]: 0 : OExternalLockGuard aGuard( this );
756 : :
757 [ # # ]: 0 : return 1;
758 : : }
759 : :
760 : : // -----------------------------------------------------------------------------
761 : :
762 : 0 : Reference< XAccessible > AccessibleTabBarPageList::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
763 : : {
764 [ # # ]: 0 : OExternalLockGuard aGuard( this );
765 : :
766 [ # # ][ # # ]: 0 : if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
[ # # ][ # # ]
767 [ # # ]: 0 : throw IndexOutOfBoundsException();
768 : :
769 : 0 : Reference< XAccessible > xChild;
770 : :
771 [ # # ][ # # ]: 0 : for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
772 : : {
773 [ # # ][ # # ]: 0 : if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
[ # # ][ # # ]
774 : : {
775 [ # # ][ # # ]: 0 : xChild = getAccessibleChild( i );
776 : 0 : break;
777 : : }
778 : : }
779 : :
780 [ # # ]: 0 : return xChild;
781 : : }
782 : :
783 : : // -----------------------------------------------------------------------------
784 : :
785 : 0 : void AccessibleTabBarPageList::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
786 : : {
787 [ # # ]: 0 : OExternalLockGuard aGuard( this );
788 : :
789 [ # # ][ # # ]: 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
[ # # ][ # # ]
790 [ # # ][ # # ]: 0 : throw IndexOutOfBoundsException();
791 : :
792 : : // This method makes no sense in a TabBar, and so does nothing.
793 : 0 : }
794 : :
795 : : // -----------------------------------------------------------------------------
796 : :
797 : : //.........................................................................
798 : : } // namespace accessibility
799 : : //.........................................................................
800 : :
801 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|