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