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/vclxaccessibletabpage.hxx> 31*cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx> 32*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 33*cdf0e10cSrcweir #include <accessibility/helper/characterattributeshelper.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 42*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 43*cdf0e10cSrcweir #include <vcl/svapp.hxx> 44*cdf0e10cSrcweir #include <vcl/unohelp2.hxx> 45*cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 46*cdf0e10cSrcweir #include <vcl/tabpage.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <memory> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 52*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 53*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 54*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 55*cdf0e10cSrcweir using namespace ::com::sun::star; 56*cdf0e10cSrcweir using namespace ::comphelper; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 60*cdf0e10cSrcweir // class VCLXAccessibleTabPage 61*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir VCLXAccessibleTabPage::VCLXAccessibleTabPage( TabControl* pTabControl, sal_uInt16 nPageId ) 64*cdf0e10cSrcweir :AccessibleTextHelper_BASE( new VCLExternalSolarLock() ) 65*cdf0e10cSrcweir ,m_pTabControl( pTabControl ) 66*cdf0e10cSrcweir ,m_nPageId( nPageId ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() ); 69*cdf0e10cSrcweir m_bFocused = IsFocused(); 70*cdf0e10cSrcweir m_bSelected = IsSelected(); 71*cdf0e10cSrcweir m_sPageText = GetPageText(); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir VCLXAccessibleTabPage::~VCLXAccessibleTabPage() 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir delete m_pExternalLock; 79*cdf0e10cSrcweir m_pExternalLock = NULL; 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir bool VCLXAccessibleTabPage::IsFocused() 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir bool bFocused = false; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if ( m_pTabControl && m_pTabControl->HasFocus() && m_pTabControl->GetCurPageId() == m_nPageId ) 89*cdf0e10cSrcweir bFocused = true; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir return bFocused; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir bool VCLXAccessibleTabPage::IsSelected() 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir bool bSelected = false; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_nPageId ) 101*cdf0e10cSrcweir bSelected = true; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir return bSelected; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void VCLXAccessibleTabPage::SetFocused( bool bFocused ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir if ( m_bFocused != bFocused ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir Any aOldValue, aNewValue; 113*cdf0e10cSrcweir if ( m_bFocused ) 114*cdf0e10cSrcweir aOldValue <<= AccessibleStateType::FOCUSED; 115*cdf0e10cSrcweir else 116*cdf0e10cSrcweir aNewValue <<= AccessibleStateType::FOCUSED; 117*cdf0e10cSrcweir m_bFocused = bFocused; 118*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir void VCLXAccessibleTabPage::SetSelected( bool bSelected ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir if ( m_bSelected != bSelected ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir Any aOldValue, aNewValue; 129*cdf0e10cSrcweir if ( m_bSelected ) 130*cdf0e10cSrcweir aOldValue <<= AccessibleStateType::SELECTED; 131*cdf0e10cSrcweir else 132*cdf0e10cSrcweir aNewValue <<= AccessibleStateType::SELECTED; 133*cdf0e10cSrcweir m_bSelected = bSelected; 134*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void VCLXAccessibleTabPage::SetPageText( const ::rtl::OUString& sPageText ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir Any aOldValue, aNewValue; 143*cdf0e10cSrcweir if ( OCommonAccessibleText::implInitTextChangedEvent( m_sPageText, sPageText, aOldValue, aNewValue ) ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir Any aOldName, aNewName; 146*cdf0e10cSrcweir aOldName <<= m_sPageText; 147*cdf0e10cSrcweir aNewName <<= sPageText; 148*cdf0e10cSrcweir m_sPageText = sPageText; 149*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldName, aNewName ); 150*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue ); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::GetPageText() 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir ::rtl::OUString sText; 159*cdf0e10cSrcweir if ( m_pTabControl ) 160*cdf0e10cSrcweir sText = OutputDevice::GetNonMnemonicString( m_pTabControl->GetPageText( m_nPageId ) ); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir return sText; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir void VCLXAccessibleTabPage::Update( bool bNew ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir if ( m_pTabControl ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId ); 172*cdf0e10cSrcweir if ( pTabPage ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir Reference< XAccessible > xChild( pTabPage->GetAccessible( bNew ) ); 175*cdf0e10cSrcweir if ( xChild.is() ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir Any aOldValue, aNewValue; 178*cdf0e10cSrcweir if ( bNew ) 179*cdf0e10cSrcweir aNewValue <<= xChild; 180*cdf0e10cSrcweir else 181*cdf0e10cSrcweir aOldValue <<= xChild; 182*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir void VCLXAccessibleTabPage::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::ENABLED ); 193*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SENSITIVE ); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir if ( IsFocused() ) 198*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED ); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SHOWING ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SELECTABLE ); 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir if ( IsSelected() ) 207*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SELECTED ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 211*cdf0e10cSrcweir // OCommonAccessibleComponent 212*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir awt::Rectangle VCLXAccessibleTabPage::implGetBounds() throw (RuntimeException) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir awt::Rectangle aBounds( 0, 0, 0, 0 ); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir if ( m_pTabControl ) 219*cdf0e10cSrcweir aBounds = AWTRectangle( m_pTabControl->GetTabBounds( m_nPageId ) ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir return aBounds; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 225*cdf0e10cSrcweir // OCommonAccessibleText 226*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::implGetText() 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir return GetPageText(); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir lang::Locale VCLXAccessibleTabPage::implGetLocale() 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir return Application::GetSettings().GetLocale(); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir void VCLXAccessibleTabPage::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir nStartIndex = 0; 245*cdf0e10cSrcweir nEndIndex = 0; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 249*cdf0e10cSrcweir // XInterface 250*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTabPage, AccessibleTextHelper_BASE, VCLXAccessibleTabPage_BASE ) 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 255*cdf0e10cSrcweir // XTypeProvider 256*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTabPage, AccessibleTextHelper_BASE, VCLXAccessibleTabPage_BASE ) 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 261*cdf0e10cSrcweir // XComponent 262*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir void VCLXAccessibleTabPage::disposing() 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir AccessibleTextHelper_BASE::disposing(); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir m_pTabControl = NULL; 269*cdf0e10cSrcweir m_sPageText = ::rtl::OUString(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 273*cdf0e10cSrcweir // XServiceInfo 274*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getImplementationName() throw (RuntimeException) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleTabPage" ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); 286*cdf0e10cSrcweir const ::rtl::OUString* pNames = aNames.getConstArray(); 287*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pNames + aNames.getLength(); 288*cdf0e10cSrcweir for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) 289*cdf0e10cSrcweir ; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir return pNames != pEnd; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleTabPage::getSupportedServiceNames() throw (RuntimeException) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(1); 299*cdf0e10cSrcweir aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabPage" ); 300*cdf0e10cSrcweir return aNames; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 304*cdf0e10cSrcweir // XAccessible 305*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir Reference< XAccessibleContext > VCLXAccessibleTabPage::getAccessibleContext( ) throw (RuntimeException) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir return this; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 315*cdf0e10cSrcweir // XAccessibleContext 316*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getAccessibleChildCount() throw (RuntimeException) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir sal_Int32 nCount = 0; 323*cdf0e10cSrcweir if ( m_pTabControl ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId ); 326*cdf0e10cSrcweir if ( pTabPage && pTabPage->IsVisible() ) 327*cdf0e10cSrcweir nCount = 1; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir return nCount; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir if ( i < 0 || i >= getAccessibleChildCount() ) 340*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir Reference< XAccessible > xChild; 343*cdf0e10cSrcweir if ( m_pTabControl ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId ); 346*cdf0e10cSrcweir if ( pTabPage && pTabPage->IsVisible() ) 347*cdf0e10cSrcweir xChild = pTabPage->GetAccessible(); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir return xChild; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleParent( ) throw (RuntimeException) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir Reference< XAccessible > xParent; 360*cdf0e10cSrcweir if ( m_pTabControl ) 361*cdf0e10cSrcweir xParent = m_pTabControl->GetAccessible(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir return xParent; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getAccessibleIndexInParent( ) throw (RuntimeException) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir sal_Int32 nIndexInParent = -1; 373*cdf0e10cSrcweir if ( m_pTabControl ) 374*cdf0e10cSrcweir nIndexInParent = m_pTabControl->GetPagePos( m_nPageId ); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir return nIndexInParent; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir sal_Int16 VCLXAccessibleTabPage::getAccessibleRole( ) throw (RuntimeException) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir return AccessibleRole::PAGE_TAB; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getAccessibleDescription( ) throw (RuntimeException) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir ::rtl::OUString sDescription; 395*cdf0e10cSrcweir if ( m_pTabControl ) 396*cdf0e10cSrcweir sDescription = m_pTabControl->GetHelpText( m_nPageId ); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir return sDescription; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getAccessibleName( ) throw (RuntimeException) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir return GetPageText(); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir Reference< XAccessibleRelationSet > VCLXAccessibleTabPage::getAccessibleRelationSet( ) throw (RuntimeException) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 417*cdf0e10cSrcweir Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; 418*cdf0e10cSrcweir return xSet; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir Reference< XAccessibleStateSet > VCLXAccessibleTabPage::getAccessibleStateSet( ) throw (RuntimeException) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 428*cdf0e10cSrcweir Reference< XAccessibleStateSet > xSet = pStateSetHelper; 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir FillAccessibleStateSet( *pStateSetHelper ); 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir else 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir return xSet; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir Locale VCLXAccessibleTabPage::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir return Application::GetSettings().GetLocale(); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 452*cdf0e10cSrcweir // XAccessibleComponent 453*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir Reference< XAccessible > xChild; 460*cdf0e10cSrcweir for ( sal_uInt32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir Reference< XAccessible > xAcc = getAccessibleChild( i ); 463*cdf0e10cSrcweir if ( xAcc.is() ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY ); 466*cdf0e10cSrcweir if ( xComp.is() ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir Rectangle aRect = VCLRectangle( xComp->getBounds() ); 469*cdf0e10cSrcweir Point aPos = VCLPoint( rPoint ); 470*cdf0e10cSrcweir if ( aRect.IsInside( aPos ) ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir xChild = xAcc; 473*cdf0e10cSrcweir break; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir return xChild; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir void VCLXAccessibleTabPage::grabFocus( ) throw (RuntimeException) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir if ( m_pTabControl ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir m_pTabControl->SelectTabPage( m_nPageId ); 491*cdf0e10cSrcweir m_pTabControl->GrabFocus(); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getForeground( ) throw (RuntimeException) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir sal_Int32 nColor = 0; 502*cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 503*cdf0e10cSrcweir if ( xParent.is() ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 506*cdf0e10cSrcweir if ( xParentComp.is() ) 507*cdf0e10cSrcweir nColor = xParentComp->getForeground(); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir return nColor; 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getBackground( ) throw (RuntimeException) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir sal_Int32 nColor = 0; 520*cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 521*cdf0e10cSrcweir if ( xParent.is() ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 524*cdf0e10cSrcweir if ( xParentComp.is() ) 525*cdf0e10cSrcweir nColor = xParentComp->getBackground(); 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir return nColor; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 532*cdf0e10cSrcweir // XAccessibleExtendedComponent 533*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir Reference< awt::XFont > VCLXAccessibleTabPage::getFont( ) throw (RuntimeException) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir Reference< awt::XFont > xFont; 540*cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 541*cdf0e10cSrcweir if ( xParent.is() ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 544*cdf0e10cSrcweir if ( xParentComp.is() ) 545*cdf0e10cSrcweir xFont = xParentComp->getFont(); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir return xFont; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getTitledBorderText( ) throw (RuntimeException) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir return ::rtl::OUString(); 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getToolTipText( ) throw (RuntimeException) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir return ::rtl::OUString(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 570*cdf0e10cSrcweir // XAccessibleText 571*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getCaretPosition() throw (RuntimeException) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir return -1; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 587*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir return sal_False; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir Sequence< PropertyValue > VCLXAccessibleTabPage::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir Sequence< PropertyValue > aValues; 599*cdf0e10cSrcweir ::rtl::OUString sText( implGetText() ); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 602*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir if ( m_pTabControl ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir Font aFont = m_pTabControl->GetFont(); 607*cdf0e10cSrcweir sal_Int32 nBackColor = getBackground(); 608*cdf0e10cSrcweir sal_Int32 nColor = getForeground(); 609*cdf0e10cSrcweir ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) ); 610*cdf0e10cSrcweir aValues = pHelper->GetCharacterAttributes( aRequestedAttributes ); 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir return aValues; 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir awt::Rectangle VCLXAccessibleTabPage::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, implGetText().getLength() ) ) 623*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir awt::Rectangle aBounds( 0, 0, 0, 0 ); 626*cdf0e10cSrcweir if ( m_pTabControl ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId ); 629*cdf0e10cSrcweir Rectangle aCharRect = m_pTabControl->GetCharacterBounds( m_nPageId, nIndex ); 630*cdf0e10cSrcweir aCharRect.Move( -aPageRect.Left(), -aPageRect.Top() ); 631*cdf0e10cSrcweir aBounds = AWTRectangle( aCharRect ); 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir return aBounds; 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir sal_Int32 nIndex = -1; 644*cdf0e10cSrcweir if ( m_pTabControl ) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir sal_uInt16 nPageId = 0; 647*cdf0e10cSrcweir Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId ); 648*cdf0e10cSrcweir Point aPnt( VCLPoint( aPoint ) ); 649*cdf0e10cSrcweir aPnt += aPageRect.TopLeft(); 650*cdf0e10cSrcweir sal_Int32 nI = m_pTabControl->GetIndexForPoint( aPnt, nPageId ); 651*cdf0e10cSrcweir if ( nI != -1 && m_nPageId == nPageId ) 652*cdf0e10cSrcweir nIndex = nI; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir return nIndex; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 665*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir return sal_False; 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir if ( m_pTabControl ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pTabControl->GetClipboard(); 681*cdf0e10cSrcweir if ( xClipboard.is() ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) ); 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText ); 686*cdf0e10cSrcweir const sal_uInt32 nRef = Application::ReleaseSolarMutex(); 687*cdf0e10cSrcweir xClipboard->setContents( pDataObj, NULL ); 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY ); 690*cdf0e10cSrcweir if( xFlushableClipboard.is() ) 691*cdf0e10cSrcweir xFlushableClipboard->flushClipboard(); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir Application::AcquireSolarMutex( nRef ); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir bReturn = sal_True; 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir return bReturn; 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 703