1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_accessibility.hxx" 30*cdf0e10cSrcweir #include <accessibility/standard/vclxaccessibletabcontrol.hxx> 31*cdf0e10cSrcweir #include <accessibility/standard/vclxaccessibletabpage.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 36*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 37*cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 38*cdf0e10cSrcweir #include <vcl/tabpage.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <vector> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir using namespace ::com::sun::star; 43*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 44*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 45*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 46*cdf0e10cSrcweir using namespace ::comphelper; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir // ---------------------------------------------------- 50*cdf0e10cSrcweir // class VCLXAccessibleTabControl 51*cdf0e10cSrcweir // ---------------------------------------------------- 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir VCLXAccessibleTabControl::VCLXAccessibleTabControl( VCLXWindow* pVCLXWindow ) 54*cdf0e10cSrcweir :VCLXAccessibleComponent( pVCLXWindow ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir m_pTabControl = static_cast< TabControl* >( GetWindow() ); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir if ( m_pTabControl ) 59*cdf0e10cSrcweir m_aAccessibleChildren.assign( m_pTabControl->GetPageCount(), Reference< XAccessible >() ); 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir VCLXAccessibleTabControl::~VCLXAccessibleTabControl() 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir void VCLXAccessibleTabControl::UpdateFocused() 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); 75*cdf0e10cSrcweir if ( xChild.is() ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); 78*cdf0e10cSrcweir if ( pVCLXAccessibleTabPage ) 79*cdf0e10cSrcweir pVCLXAccessibleTabPage->SetFocused( pVCLXAccessibleTabPage->IsFocused() ); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void VCLXAccessibleTabControl::UpdateSelected( sal_Int32 i, bool bSelected ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); 93*cdf0e10cSrcweir if ( xChild.is() ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); 96*cdf0e10cSrcweir if ( pVCLXAccessibleTabPage ) 97*cdf0e10cSrcweir pVCLXAccessibleTabPage->SetSelected( bSelected ); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir void VCLXAccessibleTabControl::UpdatePageText( sal_Int32 i ) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); 109*cdf0e10cSrcweir if ( xChild.is() ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); 112*cdf0e10cSrcweir if ( pVCLXAccessibleTabPage ) 113*cdf0e10cSrcweir pVCLXAccessibleTabPage->SetPageText( pVCLXAccessibleTabPage->GetPageText() ); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void VCLXAccessibleTabControl::UpdateTabPage( sal_Int32 i, bool bNew ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); 125*cdf0e10cSrcweir if ( xChild.is() ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); 128*cdf0e10cSrcweir if ( pVCLXAccessibleTabPage ) 129*cdf0e10cSrcweir pVCLXAccessibleTabPage->Update( bNew ); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir void VCLXAccessibleTabControl::InsertChild( sal_Int32 i ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir if ( i >= 0 && i <= (sal_Int32)m_aAccessibleChildren.size() ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir // insert entry in child list 141*cdf0e10cSrcweir m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // send accessible child event 144*cdf0e10cSrcweir Reference< XAccessible > xChild( getAccessibleChild( i ) ); 145*cdf0e10cSrcweir if ( xChild.is() ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir Any aOldValue, aNewValue; 148*cdf0e10cSrcweir aNewValue <<= xChild; 149*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir void VCLXAccessibleTabControl::RemoveChild( sal_Int32 i ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir // get the accessible of the removed page 161*cdf0e10cSrcweir Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // remove entry in child list 164*cdf0e10cSrcweir m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir // send accessible child event 167*cdf0e10cSrcweir if ( xChild.is() ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir Any aOldValue, aNewValue; 170*cdf0e10cSrcweir aOldValue <<= xChild; 171*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir Reference< XComponent > xComponent( xChild, UNO_QUERY ); 174*cdf0e10cSrcweir if ( xComponent.is() ) 175*cdf0e10cSrcweir xComponent->dispose(); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir void VCLXAccessibleTabControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir case VCLEVENT_TABPAGE_ACTIVATE: 187*cdf0e10cSrcweir case VCLEVENT_TABPAGE_DEACTIVATE: 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir if ( m_pTabControl ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData(); 192*cdf0e10cSrcweir sal_uInt16 nPagePos = m_pTabControl->GetPagePos( nPageId ); 193*cdf0e10cSrcweir UpdateFocused(); 194*cdf0e10cSrcweir UpdateSelected( nPagePos, rVclWindowEvent.GetId() == VCLEVENT_TABPAGE_ACTIVATE ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir break; 198*cdf0e10cSrcweir case VCLEVENT_TABPAGE_PAGETEXTCHANGED: 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir if ( m_pTabControl ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData(); 203*cdf0e10cSrcweir sal_uInt16 nPagePos = m_pTabControl->GetPagePos( nPageId ); 204*cdf0e10cSrcweir UpdatePageText( nPagePos ); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir break; 208*cdf0e10cSrcweir case VCLEVENT_TABPAGE_INSERTED: 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir if ( m_pTabControl ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData(); 213*cdf0e10cSrcweir sal_uInt16 nPagePos = m_pTabControl->GetPagePos( nPageId ); 214*cdf0e10cSrcweir InsertChild( nPagePos ); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir break; 218*cdf0e10cSrcweir case VCLEVENT_TABPAGE_REMOVED: 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if ( m_pTabControl ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData(); 223*cdf0e10cSrcweir for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir Reference< XAccessible > xChild( getAccessibleChild( i ) ); 226*cdf0e10cSrcweir if ( xChild.is() ) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); 229*cdf0e10cSrcweir if ( pVCLXAccessibleTabPage && pVCLXAccessibleTabPage->GetPageId() == nPageId ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir RemoveChild( i ); 232*cdf0e10cSrcweir break; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir break; 239*cdf0e10cSrcweir case VCLEVENT_TABPAGE_REMOVEDALL: 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir for ( sal_Int32 i = m_aAccessibleChildren.size() - 1; i >= 0; --i ) 242*cdf0e10cSrcweir RemoveChild( i ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir break; 245*cdf0e10cSrcweir case VCLEVENT_WINDOW_GETFOCUS: 246*cdf0e10cSrcweir case VCLEVENT_WINDOW_LOSEFOCUS: 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir UpdateFocused(); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir break; 251*cdf0e10cSrcweir case VCLEVENT_OBJECT_DYING: 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir if ( m_pTabControl ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir m_pTabControl = NULL; 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir // dispose all tab pages 258*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY ); 261*cdf0e10cSrcweir if ( xComponent.is() ) 262*cdf0e10cSrcweir xComponent->dispose(); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir m_aAccessibleChildren.clear(); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir break; 270*cdf0e10cSrcweir default: 271*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir void VCLXAccessibleTabControl::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir case VCLEVENT_WINDOW_SHOW: 282*cdf0e10cSrcweir case VCLEVENT_WINDOW_HIDE: 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir if ( m_pTabControl ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir Window* pChild = static_cast< Window* >( rVclWindowEvent.GetData() ); 287*cdf0e10cSrcweir if ( pChild && pChild->GetType() == WINDOW_TABPAGE ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir for ( sal_Int32 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir sal_uInt16 nPageId = m_pTabControl->GetPageId( (sal_uInt16)i ); 292*cdf0e10cSrcweir TabPage* pTabPage = m_pTabControl->GetTabPage( nPageId ); 293*cdf0e10cSrcweir if ( pTabPage == (TabPage*) pChild ) 294*cdf0e10cSrcweir UpdateTabPage( i, rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir break; 300*cdf0e10cSrcweir default: 301*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent ); 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir void VCLXAccessibleTabControl::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir if ( m_pTabControl ) 313*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 317*cdf0e10cSrcweir // XInterface 318*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTabControl, VCLXAccessibleComponent, VCLXAccessibleTabControl_BASE ) 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 323*cdf0e10cSrcweir // XTypeProvider 324*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTabControl, VCLXAccessibleComponent, VCLXAccessibleTabControl_BASE ) 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 329*cdf0e10cSrcweir // XComponent 330*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir void VCLXAccessibleTabControl::disposing() 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir VCLXAccessibleComponent::disposing(); 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir if ( m_pTabControl ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir m_pTabControl = NULL; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir // dispose all tab pages 341*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY ); 344*cdf0e10cSrcweir if ( xComponent.is() ) 345*cdf0e10cSrcweir xComponent->dispose(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir m_aAccessibleChildren.clear(); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 352*cdf0e10cSrcweir // XServiceInfo 353*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabControl::getImplementationName() throw (RuntimeException) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleTabControl" ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleTabControl::getSupportedServiceNames() throw (RuntimeException) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(1); 365*cdf0e10cSrcweir aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabControl" ); 366*cdf0e10cSrcweir return aNames; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 370*cdf0e10cSrcweir // XAccessibleContext 371*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabControl::getAccessibleChildCount() throw (RuntimeException) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir return m_aAccessibleChildren.size(); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabControl::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir if ( i < 0 || i >= getAccessibleChildCount() ) 387*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir Reference< XAccessible > xChild = m_aAccessibleChildren[i]; 390*cdf0e10cSrcweir if ( !xChild.is() ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir if ( m_pTabControl ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir sal_uInt16 nPageId = m_pTabControl->GetPageId( (sal_uInt16)i ); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir xChild = new VCLXAccessibleTabPage( m_pTabControl, nPageId ); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir // insert into tab page list 399*cdf0e10cSrcweir m_aAccessibleChildren[i] = xChild; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir return xChild; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir sal_Int16 VCLXAccessibleTabControl::getAccessibleRole( ) throw (RuntimeException) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir return AccessibleRole::PAGE_TAB_LIST; 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabControl::getAccessibleName( ) throw (RuntimeException) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir return ::rtl::OUString(); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 425*cdf0e10cSrcweir // XAccessibleSelection 426*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir void VCLXAccessibleTabControl::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) 433*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir if ( m_pTabControl ) 436*cdf0e10cSrcweir m_pTabControl->SelectTabPage( m_pTabControl->GetPageId( (sal_uInt16)nChildIndex ) ); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir sal_Bool VCLXAccessibleTabControl::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) 446*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir sal_Bool bSelected = sal_False; 449*cdf0e10cSrcweir if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_pTabControl->GetPageId( (sal_uInt16)nChildIndex ) ) 450*cdf0e10cSrcweir bSelected = sal_True; 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir return bSelected; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void VCLXAccessibleTabControl::clearAccessibleSelection( ) throw (RuntimeException) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir // This method makes no sense in a tab control, and so does nothing. 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir void VCLXAccessibleTabControl::selectAllAccessibleChildren( ) throw (RuntimeException) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir selectAccessibleChild( 0 ); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabControl::getSelectedAccessibleChildCount( ) throw (RuntimeException) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir return 1; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabControl::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 487*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir Reference< XAccessible > xChild; 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir xChild = getAccessibleChild( i ); 496*cdf0e10cSrcweir break; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir return xChild; 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir void VCLXAccessibleTabControl::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) 510*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir // This method makes no sense in a tab control, and so does nothing. 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 516