update dev300-m58
[ooovba.git] / accessibility / source / extended / accessibletabbarpagelist.cxx
blobcbd98d3f6ec64ea28cc31ade6af6d24caeef1957
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibletabbarpagelist.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
33 #include <accessibility/extended/accessibletabbarpagelist.hxx>
34 #include <svtools/tabbar.hxx>
35 #include <accessibility/extended/accessibletabbarpage.hxx>
36 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
37 #include <com/sun/star/accessibility/AccessibleRole.hpp>
38 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
39 #include <unotools/accessiblestatesethelper.hxx>
40 #include <unotools/accessiblerelationsethelper.hxx>
41 #include <tools/debug.hxx>
42 #include <vcl/svapp.hxx>
43 #include <toolkit/helper/convert.hxx>
46 //.........................................................................
47 namespace accessibility
49 //.........................................................................
51 using namespace ::com::sun::star::accessibility;
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star;
55 using namespace ::comphelper;
57 DBG_NAME( AccessibleTabBarPageList )
59 // -----------------------------------------------------------------------------
60 // class AccessibleTabBarPageList
61 // -----------------------------------------------------------------------------
63 AccessibleTabBarPageList::AccessibleTabBarPageList( TabBar* pTabBar, sal_Int32 nIndexInParent )
64 :AccessibleTabBarBase( pTabBar )
65 ,m_nIndexInParent( nIndexInParent )
67 DBG_CTOR( AccessibleTabBarPageList, NULL );
68 if ( m_pTabBar )
69 m_aAccessibleChildren.assign( m_pTabBar->GetPageCount(), Reference< XAccessible >() );
72 // -----------------------------------------------------------------------------
74 AccessibleTabBarPageList::~AccessibleTabBarPageList()
76 DBG_DTOR( AccessibleTabBarPageList, NULL );
79 // -----------------------------------------------------------------------------
81 void AccessibleTabBarPageList::UpdateEnabled( sal_Int32 i, sal_Bool bEnabled )
83 if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
85 Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
86 if ( xChild.is() )
88 AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
89 if ( pAccessibleTabBarPage )
90 pAccessibleTabBarPage->SetEnabled( bEnabled );
95 // -----------------------------------------------------------------------------
97 void AccessibleTabBarPageList::UpdateShowing( sal_Bool bShowing )
99 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
101 Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
102 if ( xChild.is() )
104 AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
105 if ( pAccessibleTabBarPage )
106 pAccessibleTabBarPage->SetShowing( bShowing );
111 // -----------------------------------------------------------------------------
113 void AccessibleTabBarPageList::UpdateSelected( sal_Int32 i, sal_Bool bSelected )
115 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
117 if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
119 Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
120 if ( xChild.is() )
122 AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
123 if ( pAccessibleTabBarPage )
124 pAccessibleTabBarPage->SetSelected( bSelected );
129 // -----------------------------------------------------------------------------
131 void AccessibleTabBarPageList::UpdatePageText( sal_Int32 i )
133 if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
135 Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
136 if ( xChild.is() )
138 AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
139 if ( pAccessibleTabBarPage )
141 if ( m_pTabBar )
143 ::rtl::OUString sPageText = m_pTabBar->GetPageText( m_pTabBar->GetPageId( (sal_uInt16)i ) );
144 pAccessibleTabBarPage->SetPageText( sPageText );
151 // -----------------------------------------------------------------------------
153 void AccessibleTabBarPageList::InsertChild( sal_Int32 i )
155 if ( i >= 0 && i <= (sal_Int32)m_aAccessibleChildren.size() )
157 // insert entry in child list
158 m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
160 // send accessible child event
161 Reference< XAccessible > xChild( getAccessibleChild( i ) );
162 if ( xChild.is() )
164 Any aOldValue, aNewValue;
165 aNewValue <<= xChild;
166 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
171 // -----------------------------------------------------------------------------
173 void AccessibleTabBarPageList::RemoveChild( sal_Int32 i )
175 if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
177 // get the accessible of the removed page
178 Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
180 // remove entry in child list
181 m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
183 // send accessible child event
184 if ( xChild.is() )
186 Any aOldValue, aNewValue;
187 aOldValue <<= xChild;
188 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
190 Reference< XComponent > xComponent( xChild, UNO_QUERY );
191 if ( xComponent.is() )
192 xComponent->dispose();
197 // -----------------------------------------------------------------------------
199 void AccessibleTabBarPageList::MoveChild( sal_Int32 i, sal_Int32 j )
201 if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() &&
202 j >= 0 && j <= (sal_Int32)m_aAccessibleChildren.size() )
204 if ( i < j )
205 --j;
207 // get the accessible of the moved page
208 Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
210 // remove entry in child list at old position
211 m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
213 // insert entry in child list at new position
214 m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + j, xChild );
218 // -----------------------------------------------------------------------------
220 void AccessibleTabBarPageList::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
222 switch ( rVclWindowEvent.GetId() )
224 case VCLEVENT_WINDOW_ENABLED:
226 Any aNewValue;
227 aNewValue <<= AccessibleStateType::SENSITIVE;
228 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), aNewValue );
229 aNewValue <<= AccessibleStateType::ENABLED;
230 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), aNewValue );
232 break;
233 case VCLEVENT_WINDOW_DISABLED:
235 Any aOldValue;
236 aOldValue <<= AccessibleStateType::ENABLED;
237 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, Any() );
238 aOldValue <<= AccessibleStateType::SENSITIVE;
239 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, Any() );
241 break;
242 case VCLEVENT_WINDOW_SHOW:
244 Any aOldValue, aNewValue;
245 aNewValue <<= AccessibleStateType::SHOWING;
246 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
247 UpdateShowing( sal_True );
249 break;
250 case VCLEVENT_WINDOW_HIDE:
252 Any aOldValue, aNewValue;
253 aOldValue <<= AccessibleStateType::SHOWING;
254 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
255 UpdateShowing( sal_False );
257 break;
258 case VCLEVENT_TABBAR_PAGEENABLED:
260 if ( m_pTabBar )
262 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
263 sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
264 UpdateEnabled( nPagePos, sal_True );
267 break;
268 case VCLEVENT_TABBAR_PAGEDISABLED:
270 if ( m_pTabBar )
272 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
273 sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
274 UpdateEnabled( nPagePos, sal_False );
277 break;
278 case VCLEVENT_TABBAR_PAGESELECTED:
280 // do nothing
282 break;
283 case VCLEVENT_TABBAR_PAGEACTIVATED:
285 if ( m_pTabBar )
287 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
288 sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
289 UpdateSelected( nPagePos, sal_True );
292 break;
293 case VCLEVENT_TABBAR_PAGEDEACTIVATED:
295 if ( m_pTabBar )
297 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
298 sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
299 UpdateSelected( nPagePos, sal_False );
302 break;
303 case VCLEVENT_TABBAR_PAGEINSERTED:
305 if ( m_pTabBar )
307 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
308 sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
309 InsertChild( nPagePos );
312 break;
313 case VCLEVENT_TABBAR_PAGEREMOVED:
315 if ( m_pTabBar )
317 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
319 if ( nPageId == TABBAR_PAGE_NOTFOUND )
321 for ( sal_Int32 i = m_aAccessibleChildren.size() - 1; i >= 0; --i )
322 RemoveChild( i );
324 else
326 for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
328 Reference< XAccessible > xChild( getAccessibleChild( i ) );
329 if ( xChild.is() )
331 AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
332 if ( pAccessibleTabBarPage && pAccessibleTabBarPage->GetPageId() == nPageId )
334 RemoveChild( i );
335 break;
342 break;
343 case VCLEVENT_TABBAR_PAGEMOVED:
345 Pair* pPair = (Pair*) rVclWindowEvent.GetData();
346 if ( pPair )
347 MoveChild( pPair->A(), pPair->B() );
349 break;
350 case VCLEVENT_TABBAR_PAGETEXTCHANGED:
352 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
353 sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
354 UpdatePageText( nPagePos );
356 break;
357 default:
359 AccessibleTabBarBase::ProcessWindowEvent( rVclWindowEvent );
361 break;
365 // -----------------------------------------------------------------------------
367 void AccessibleTabBarPageList::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
369 if ( m_pTabBar )
371 if ( m_pTabBar->IsEnabled() )
373 rStateSet.AddState( AccessibleStateType::ENABLED );
374 rStateSet.AddState( AccessibleStateType::SENSITIVE );
377 rStateSet.AddState( AccessibleStateType::VISIBLE );
379 if ( m_pTabBar->IsVisible() )
380 rStateSet.AddState( AccessibleStateType::SHOWING );
384 // -----------------------------------------------------------------------------
385 // OCommonAccessibleComponent
386 // -----------------------------------------------------------------------------
388 awt::Rectangle AccessibleTabBarPageList::implGetBounds() throw (RuntimeException)
390 awt::Rectangle aBounds;
391 if ( m_pTabBar )
392 aBounds = AWTRectangle( m_pTabBar->GetPageArea() );
394 return aBounds;
397 // -----------------------------------------------------------------------------
398 // XInterface
399 // -----------------------------------------------------------------------------
401 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabBarPageList, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPageList_BASE )
403 // -----------------------------------------------------------------------------
404 // XTypeProvider
405 // -----------------------------------------------------------------------------
407 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabBarPageList, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPageList_BASE )
409 // -----------------------------------------------------------------------------
410 // XComponent
411 // -----------------------------------------------------------------------------
413 void AccessibleTabBarPageList::disposing()
415 AccessibleTabBarBase::disposing();
417 // dispose all children
418 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
420 Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
421 if ( xComponent.is() )
422 xComponent->dispose();
424 m_aAccessibleChildren.clear();
427 // -----------------------------------------------------------------------------
428 // XServiceInfo
429 // -----------------------------------------------------------------------------
431 ::rtl::OUString AccessibleTabBarPageList::getImplementationName() throw (RuntimeException)
433 return ::rtl::OUString::createFromAscii( "com.sun.star.comp.svtools.AccessibleTabBarPageList" );
436 // -----------------------------------------------------------------------------
438 sal_Bool AccessibleTabBarPageList::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
440 Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
441 const ::rtl::OUString* pNames = aNames.getConstArray();
442 const ::rtl::OUString* pEnd = pNames + aNames.getLength();
443 for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
446 return pNames != pEnd;
449 // -----------------------------------------------------------------------------
451 Sequence< ::rtl::OUString > AccessibleTabBarPageList::getSupportedServiceNames() throw (RuntimeException)
453 Sequence< ::rtl::OUString > aNames(1);
454 aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabBarPageList" );
455 return aNames;
458 // -----------------------------------------------------------------------------
459 // XAccessible
460 // -----------------------------------------------------------------------------
462 Reference< XAccessibleContext > AccessibleTabBarPageList::getAccessibleContext( ) throw (RuntimeException)
464 OExternalLockGuard aGuard( this );
466 return this;
469 // -----------------------------------------------------------------------------
470 // XAccessibleContext
471 // -----------------------------------------------------------------------------
473 sal_Int32 AccessibleTabBarPageList::getAccessibleChildCount() throw (RuntimeException)
475 OExternalLockGuard aGuard( this );
477 return m_aAccessibleChildren.size();
480 // -----------------------------------------------------------------------------
482 Reference< XAccessible > AccessibleTabBarPageList::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
484 OExternalLockGuard aGuard( this );
486 if ( i < 0 || i >= getAccessibleChildCount() )
487 throw IndexOutOfBoundsException();
489 Reference< XAccessible > xChild = m_aAccessibleChildren[i];
490 if ( !xChild.is() )
492 if ( m_pTabBar )
494 sal_uInt16 nPageId = m_pTabBar->GetPageId( (USHORT)i );
496 xChild = new AccessibleTabBarPage( m_pTabBar, nPageId, this );
498 // insert into child list
499 m_aAccessibleChildren[i] = xChild;
503 return xChild;
506 // -----------------------------------------------------------------------------
508 Reference< XAccessible > AccessibleTabBarPageList::getAccessibleParent( ) throw (RuntimeException)
510 OExternalLockGuard aGuard( this );
512 Reference< XAccessible > xParent;
513 if ( m_pTabBar )
514 xParent = m_pTabBar->GetAccessible();
516 return xParent;
519 // -----------------------------------------------------------------------------
521 sal_Int32 AccessibleTabBarPageList::getAccessibleIndexInParent( ) throw (RuntimeException)
523 OExternalLockGuard aGuard( this );
525 return m_nIndexInParent;
528 // -----------------------------------------------------------------------------
530 sal_Int16 AccessibleTabBarPageList::getAccessibleRole( ) throw (RuntimeException)
532 OExternalLockGuard aGuard( this );
534 return AccessibleRole::PAGE_TAB_LIST;
537 // -----------------------------------------------------------------------------
539 ::rtl::OUString AccessibleTabBarPageList::getAccessibleDescription( ) throw (RuntimeException)
541 OExternalLockGuard aGuard( this );
543 return ::rtl::OUString();
546 // -----------------------------------------------------------------------------
548 ::rtl::OUString AccessibleTabBarPageList::getAccessibleName( ) throw (RuntimeException)
550 OExternalLockGuard aGuard( this );
552 return ::rtl::OUString();
555 // -----------------------------------------------------------------------------
557 Reference< XAccessibleRelationSet > AccessibleTabBarPageList::getAccessibleRelationSet( ) throw (RuntimeException)
559 OExternalLockGuard aGuard( this );
561 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
562 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
563 return xSet;
566 // -----------------------------------------------------------------------------
568 Reference< XAccessibleStateSet > AccessibleTabBarPageList::getAccessibleStateSet( ) throw (RuntimeException)
570 OExternalLockGuard aGuard( this );
572 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
573 Reference< XAccessibleStateSet > xSet = pStateSetHelper;
575 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
577 FillAccessibleStateSet( *pStateSetHelper );
579 else
581 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
584 return xSet;
587 // -----------------------------------------------------------------------------
589 Locale AccessibleTabBarPageList::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
591 OExternalLockGuard aGuard( this );
593 return Application::GetSettings().GetLocale();
596 // -----------------------------------------------------------------------------
597 // XAccessibleComponent
598 // -----------------------------------------------------------------------------
600 Reference< XAccessible > AccessibleTabBarPageList::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
602 OExternalLockGuard aGuard( this );
604 Reference< XAccessible > xChild;
605 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
607 Reference< XAccessible > xAcc = getAccessibleChild( i );
608 if ( xAcc.is() )
610 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
611 if ( xComp.is() )
613 Rectangle aRect = VCLRectangle( xComp->getBounds() );
614 Point aPos = VCLPoint( rPoint );
615 if ( aRect.IsInside( aPos ) )
617 xChild = xAcc;
618 break;
624 return xChild;
627 // -----------------------------------------------------------------------------
629 void AccessibleTabBarPageList::grabFocus( ) throw (RuntimeException)
631 // no focus
634 // -----------------------------------------------------------------------------
636 sal_Int32 AccessibleTabBarPageList::getForeground( ) throw (RuntimeException)
638 OExternalLockGuard aGuard( this );
640 sal_Int32 nColor = 0;
641 Reference< XAccessible > xParent = getAccessibleParent();
642 if ( xParent.is() )
644 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
645 if ( xParentComp.is() )
646 nColor = xParentComp->getForeground();
649 return nColor;
652 // -----------------------------------------------------------------------------
654 sal_Int32 AccessibleTabBarPageList::getBackground( ) throw (RuntimeException)
656 OExternalLockGuard aGuard( this );
658 sal_Int32 nColor = 0;
659 Reference< XAccessible > xParent = getAccessibleParent();
660 if ( xParent.is() )
662 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
663 if ( xParentComp.is() )
664 nColor = xParentComp->getBackground();
667 return nColor;
670 // -----------------------------------------------------------------------------
671 // XAccessibleExtendedComponent
672 // -----------------------------------------------------------------------------
674 Reference< awt::XFont > AccessibleTabBarPageList::getFont( ) throw (RuntimeException)
676 OExternalLockGuard aGuard( this );
678 Reference< awt::XFont > xFont;
679 Reference< XAccessible > xParent = getAccessibleParent();
680 if ( xParent.is() )
682 Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
683 if ( xParentComp.is() )
684 xFont = xParentComp->getFont();
687 return xFont;
690 // -----------------------------------------------------------------------------
692 ::rtl::OUString AccessibleTabBarPageList::getTitledBorderText( ) throw (RuntimeException)
694 OExternalLockGuard aGuard( this );
696 return ::rtl::OUString();
699 // -----------------------------------------------------------------------------
701 ::rtl::OUString AccessibleTabBarPageList::getToolTipText( ) throw (RuntimeException)
703 OExternalLockGuard aGuard( this );
705 return ::rtl::OUString();
708 // -----------------------------------------------------------------------------
709 // XAccessibleSelection
710 // -----------------------------------------------------------------------------
712 void AccessibleTabBarPageList::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
714 OExternalLockGuard aGuard( this );
716 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
717 throw IndexOutOfBoundsException();
719 if ( m_pTabBar )
721 m_pTabBar->SetCurPageId( m_pTabBar->GetPageId( (USHORT)nChildIndex ) );
722 m_pTabBar->Update();
723 m_pTabBar->ActivatePage();
724 m_pTabBar->Select();
728 // -----------------------------------------------------------------------------
730 sal_Bool AccessibleTabBarPageList::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
732 OExternalLockGuard aGuard( this );
734 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
735 throw IndexOutOfBoundsException();
737 sal_Bool bSelected = sal_False;
738 if ( m_pTabBar && m_pTabBar->GetCurPageId() == m_pTabBar->GetPageId( (USHORT)nChildIndex ) )
739 bSelected = sal_True;
741 return bSelected;
744 // -----------------------------------------------------------------------------
746 void AccessibleTabBarPageList::clearAccessibleSelection( ) throw (RuntimeException)
748 // This method makes no sense in a TabBar, and so does nothing.
751 // -----------------------------------------------------------------------------
753 void AccessibleTabBarPageList::selectAllAccessibleChildren( ) throw (RuntimeException)
755 OExternalLockGuard aGuard( this );
757 selectAccessibleChild( 0 );
760 // -----------------------------------------------------------------------------
762 sal_Int32 AccessibleTabBarPageList::getSelectedAccessibleChildCount( ) throw (RuntimeException)
764 OExternalLockGuard aGuard( this );
766 return 1;
769 // -----------------------------------------------------------------------------
771 Reference< XAccessible > AccessibleTabBarPageList::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
773 OExternalLockGuard aGuard( this );
775 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
776 throw IndexOutOfBoundsException();
778 Reference< XAccessible > xChild;
780 for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
782 if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
784 xChild = getAccessibleChild( i );
785 break;
789 return xChild;
792 // -----------------------------------------------------------------------------
794 void AccessibleTabBarPageList::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
796 OExternalLockGuard aGuard( this );
798 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
799 throw IndexOutOfBoundsException();
801 // This method makes no sense in a TabBar, and so does nothing.
804 // -----------------------------------------------------------------------------
806 //.........................................................................
807 } // namespace accessibility
808 //.........................................................................