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/extended/AccessibleBrowseBoxBase.hxx" 31*cdf0e10cSrcweir #include <svtools/accessibletableprovider.hxx> 32*cdf0e10cSrcweir #include <rtl/uuid.h> 33*cdf0e10cSrcweir // 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 36*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir // ============================================================================ 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir using ::rtl::OUString; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 43*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 44*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir using namespace ::com::sun::star; 47*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 48*cdf0e10cSrcweir using namespace ::comphelper; 49*cdf0e10cSrcweir using namespace ::svt; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir // ============================================================================ 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir namespace accessibility { 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir using namespace com::sun::star::accessibility::AccessibleStateType; 57*cdf0e10cSrcweir // ============================================================================ 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // Ctor/Dtor/disposing -------------------------------------------------------- 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir DBG_NAME( AccessibleBrowseBoxBase ) 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir AccessibleBrowseBoxBase::AccessibleBrowseBoxBase( 64*cdf0e10cSrcweir const Reference< XAccessible >& rxParent, 65*cdf0e10cSrcweir IAccessibleTableProvider& rBrowseBox, 66*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow, 67*cdf0e10cSrcweir AccessibleBrowseBoxObjType eObjType ) : 68*cdf0e10cSrcweir AccessibleBrowseBoxImplHelper( m_aMutex ), 69*cdf0e10cSrcweir mxParent( rxParent ), 70*cdf0e10cSrcweir mpBrowseBox( &rBrowseBox ), 71*cdf0e10cSrcweir m_xFocusWindow(_xFocusWindow), 72*cdf0e10cSrcweir maName( rBrowseBox.GetAccessibleObjectName( eObjType ) ), 73*cdf0e10cSrcweir maDescription( rBrowseBox.GetAccessibleObjectDescription( eObjType ) ), 74*cdf0e10cSrcweir meObjType( eObjType ), 75*cdf0e10cSrcweir m_aClientId(0) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir DBG_CTOR( AccessibleBrowseBoxBase, NULL ); 78*cdf0e10cSrcweir if ( m_xFocusWindow.is() ) 79*cdf0e10cSrcweir m_xFocusWindow->addFocusListener( this ); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir AccessibleBrowseBoxBase::AccessibleBrowseBoxBase( 83*cdf0e10cSrcweir const Reference< XAccessible >& rxParent, 84*cdf0e10cSrcweir IAccessibleTableProvider& rBrowseBox, 85*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow, 86*cdf0e10cSrcweir AccessibleBrowseBoxObjType eObjType, 87*cdf0e10cSrcweir const ::rtl::OUString& rName, 88*cdf0e10cSrcweir const ::rtl::OUString& rDescription ) : 89*cdf0e10cSrcweir AccessibleBrowseBoxImplHelper( m_aMutex ), 90*cdf0e10cSrcweir mxParent( rxParent ), 91*cdf0e10cSrcweir mpBrowseBox( &rBrowseBox ), 92*cdf0e10cSrcweir m_xFocusWindow(_xFocusWindow), 93*cdf0e10cSrcweir maName( rName ), 94*cdf0e10cSrcweir maDescription( rDescription ), 95*cdf0e10cSrcweir meObjType( eObjType ), 96*cdf0e10cSrcweir m_aClientId(0) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir DBG_CTOR( AccessibleBrowseBoxBase, NULL ); 99*cdf0e10cSrcweir if ( m_xFocusWindow.is() ) 100*cdf0e10cSrcweir m_xFocusWindow->addFocusListener( this ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir AccessibleBrowseBoxBase::~AccessibleBrowseBoxBase() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir DBG_DTOR( AccessibleBrowseBoxBase, NULL ); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir if( isAlive() ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir // increment ref count to prevent double call of Dtor 110*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 111*cdf0e10cSrcweir dispose(); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::disposing() 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 118*cdf0e10cSrcweir if ( m_xFocusWindow.is() ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 121*cdf0e10cSrcweir m_xFocusWindow->removeFocusListener( this ); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if ( getClientId( ) ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir AccessibleEventNotifier::TClientId nId( getClientId( ) ); 127*cdf0e10cSrcweir setClientId( 0 ); 128*cdf0e10cSrcweir AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir mxParent = NULL; 132*cdf0e10cSrcweir mpBrowseBox = NULL; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // XAccessibleContext --------------------------------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleBrowseBoxBase::getAccessibleParent() 138*cdf0e10cSrcweir throw ( uno::RuntimeException ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 141*cdf0e10cSrcweir ensureIsAlive(); 142*cdf0e10cSrcweir return mxParent; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxBase::getAccessibleIndexInParent() 146*cdf0e10cSrcweir throw ( uno::RuntimeException ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 149*cdf0e10cSrcweir ensureIsAlive(); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // -1 for child not found/no parent (according to specification) 152*cdf0e10cSrcweir sal_Int32 nRet = -1; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir Reference< uno::XInterface > xMeMyselfAndI( static_cast< XAccessibleContext* >( this ), uno::UNO_QUERY ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // iterate over parent's children and search for this object 157*cdf0e10cSrcweir if( mxParent.is() ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir Reference< XAccessibleContext > 160*cdf0e10cSrcweir xParentContext( mxParent->getAccessibleContext() ); 161*cdf0e10cSrcweir if( xParentContext.is() ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir Reference< uno::XInterface > xChild; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); 166*cdf0e10cSrcweir for( sal_Int32 nChild = 0; nChild < nChildCount; ++nChild ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir xChild = xChild.query( xParentContext->getAccessibleChild( nChild ) ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir if ( xMeMyselfAndI.get() == xChild.get() ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir nRet = nChild; 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir return nRet; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir OUString SAL_CALL AccessibleBrowseBoxBase::getAccessibleDescription() 182*cdf0e10cSrcweir throw ( uno::RuntimeException ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 185*cdf0e10cSrcweir ensureIsAlive(); 186*cdf0e10cSrcweir return maDescription; 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir OUString SAL_CALL AccessibleBrowseBoxBase::getAccessibleName() 190*cdf0e10cSrcweir throw ( uno::RuntimeException ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 193*cdf0e10cSrcweir ensureIsAlive(); 194*cdf0e10cSrcweir return maName; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL 198*cdf0e10cSrcweir AccessibleBrowseBoxBase::getAccessibleRelationSet() 199*cdf0e10cSrcweir throw ( uno::RuntimeException ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir ensureIsAlive(); 202*cdf0e10cSrcweir // BrowseBox does not have relations. 203*cdf0e10cSrcweir return new utl::AccessibleRelationSetHelper; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL 207*cdf0e10cSrcweir AccessibleBrowseBoxBase::getAccessibleStateSet() 208*cdf0e10cSrcweir throw ( uno::RuntimeException ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 211*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 212*cdf0e10cSrcweir // don't check whether alive -> StateSet may contain DEFUNC 213*cdf0e10cSrcweir return implCreateStateSetHelper(); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleBrowseBoxBase::getLocale() 217*cdf0e10cSrcweir throw ( IllegalAccessibleComponentStateException, uno::RuntimeException ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 220*cdf0e10cSrcweir ensureIsAlive(); 221*cdf0e10cSrcweir if( mxParent.is() ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir Reference< XAccessibleContext > 224*cdf0e10cSrcweir xParentContext( mxParent->getAccessibleContext() ); 225*cdf0e10cSrcweir if( xParentContext.is() ) 226*cdf0e10cSrcweir return xParentContext->getLocale(); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir throw IllegalAccessibleComponentStateException(); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir // XAccessibleComponent ------------------------------------------------------- 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::containsPoint( const awt::Point& rPoint ) 234*cdf0e10cSrcweir throw ( uno::RuntimeException ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir return Rectangle( Point(), getBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleBrowseBoxBase::getBounds() 240*cdf0e10cSrcweir throw ( uno::RuntimeException ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir return AWTRectangle( getBoundingBox() ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir awt::Point SAL_CALL AccessibleBrowseBoxBase::getLocation() 246*cdf0e10cSrcweir throw ( uno::RuntimeException ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir return AWTPoint( getBoundingBox().TopLeft() ); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir awt::Point SAL_CALL AccessibleBrowseBoxBase::getLocationOnScreen() 252*cdf0e10cSrcweir throw ( uno::RuntimeException ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir return AWTPoint( getBoundingBoxOnScreen().TopLeft() ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir awt::Size SAL_CALL AccessibleBrowseBoxBase::getSize() 258*cdf0e10cSrcweir throw ( uno::RuntimeException ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir return AWTSize( getBoundingBox().GetSize() ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::isShowing() 264*cdf0e10cSrcweir throw ( uno::RuntimeException ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 267*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 268*cdf0e10cSrcweir ensureIsAlive(); 269*cdf0e10cSrcweir return implIsShowing(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::isVisible() 273*cdf0e10cSrcweir throw ( uno::RuntimeException ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet(); 276*cdf0e10cSrcweir return xStateSet.is() ? 277*cdf0e10cSrcweir xStateSet->contains( AccessibleStateType::VISIBLE ) : sal_False; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::isFocusTraversable() 281*cdf0e10cSrcweir throw ( uno::RuntimeException ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet(); 284*cdf0e10cSrcweir return xStateSet.is() ? 285*cdf0e10cSrcweir xStateSet->contains( AccessibleStateType::FOCUSABLE ) : sal_False; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::focusGained( const ::com::sun::star::awt::FocusEvent& ) throw (::com::sun::star::uno::RuntimeException) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir com::sun::star::uno::Any aFocused; 291*cdf0e10cSrcweir com::sun::star::uno::Any aEmpty; 292*cdf0e10cSrcweir aFocused <<= FOCUSED; 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir commitEvent(AccessibleEventId::STATE_CHANGED,aFocused,aEmpty); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::focusLost( const ::com::sun::star::awt::FocusEvent& ) throw (::com::sun::star::uno::RuntimeException) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir com::sun::star::uno::Any aFocused; 301*cdf0e10cSrcweir com::sun::star::uno::Any aEmpty; 302*cdf0e10cSrcweir aFocused <<= FOCUSED; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir commitEvent(AccessibleEventId::STATE_CHANGED,aEmpty,aFocused); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir // XAccessibleEventBroadcaster ------------------------------------------------ 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::addEventListener( 309*cdf0e10cSrcweir const Reference< XAccessibleEventListener>& _rxListener ) 310*cdf0e10cSrcweir throw ( uno::RuntimeException ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir if ( _rxListener.is() ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 315*cdf0e10cSrcweir if ( !getClientId( ) ) 316*cdf0e10cSrcweir setClientId( AccessibleEventNotifier::registerClient( ) ); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir AccessibleEventNotifier::addEventListener( getClientId( ), _rxListener ); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::removeEventListener( 323*cdf0e10cSrcweir const Reference< XAccessibleEventListener>& _rxListener ) 324*cdf0e10cSrcweir throw ( uno::RuntimeException ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir if( _rxListener.is() && getClientId( ) ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 329*cdf0e10cSrcweir sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener ); 330*cdf0e10cSrcweir if ( !nListenerCount ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir // no listeners anymore 333*cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 334*cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls 335*cdf0e10cSrcweir // NotifyAccessibleEvent, again 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir AccessibleEventNotifier::TClientId nId( getClientId( ) ); 338*cdf0e10cSrcweir setClientId( 0 ); 339*cdf0e10cSrcweir AccessibleEventNotifier::revokeClient( nId ); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // XTypeProvider -------------------------------------------------------------- 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxBase::getImplementationId() 347*cdf0e10cSrcweir throw ( uno::RuntimeException ) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslGlobalMutex() ); 350*cdf0e10cSrcweir static Sequence< sal_Int8 > aId; 351*cdf0e10cSrcweir implCreateUuid( aId ); 352*cdf0e10cSrcweir return aId; 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir // XServiceInfo --------------------------------------------------------------- 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::supportsService( 358*cdf0e10cSrcweir const OUString& rServiceName ) 359*cdf0e10cSrcweir throw ( uno::RuntimeException ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir Sequence< OUString > aSupportedServices( getSupportedServiceNames() ); 364*cdf0e10cSrcweir const OUString* pArrBegin = aSupportedServices.getConstArray(); 365*cdf0e10cSrcweir const OUString* pArrEnd = pArrBegin + aSupportedServices.getLength(); 366*cdf0e10cSrcweir const OUString* pString = pArrBegin; 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir for( ; ( pString != pArrEnd ) && ( rServiceName != *pString ); ++pString ) 369*cdf0e10cSrcweir ; 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir return pString != pArrEnd; 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir Sequence< OUString > SAL_CALL AccessibleBrowseBoxBase::getSupportedServiceNames() 375*cdf0e10cSrcweir throw ( uno::RuntimeException ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); 378*cdf0e10cSrcweir return Sequence< OUString >( &aServiceName, 1 ); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir // other public methods ------------------------------------------------------- 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void AccessibleBrowseBoxBase::setAccessibleName( const OUString& rName ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() ); 386*cdf0e10cSrcweir Any aOld; 387*cdf0e10cSrcweir aOld <<= maName; 388*cdf0e10cSrcweir maName = rName; 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir aGuard.clear(); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir commitEvent( 393*cdf0e10cSrcweir AccessibleEventId::NAME_CHANGED, 394*cdf0e10cSrcweir uno::makeAny( maName ), 395*cdf0e10cSrcweir aOld ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir void AccessibleBrowseBoxBase::setAccessibleDescription( const OUString& rDescription ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() ); 401*cdf0e10cSrcweir Any aOld; 402*cdf0e10cSrcweir aOld <<= maDescription; 403*cdf0e10cSrcweir maDescription = rDescription; 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir aGuard.clear(); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir commitEvent( 408*cdf0e10cSrcweir AccessibleEventId::DESCRIPTION_CHANGED, 409*cdf0e10cSrcweir uno::makeAny( maDescription ), 410*cdf0e10cSrcweir aOld ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir // internal virtual methods --------------------------------------------------- 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir sal_Bool AccessibleBrowseBoxBase::implIsShowing() 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir sal_Bool bShowing = sal_False; 418*cdf0e10cSrcweir if( mxParent.is() ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir Reference< XAccessibleComponent > 421*cdf0e10cSrcweir xParentComp( mxParent->getAccessibleContext(), uno::UNO_QUERY ); 422*cdf0e10cSrcweir if( xParentComp.is() ) 423*cdf0e10cSrcweir bShowing = implGetBoundingBox().IsOver( 424*cdf0e10cSrcweir VCLRectangle( xParentComp->getBounds() ) ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir return bShowing; 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxBase::implCreateStateSetHelper() 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* 432*cdf0e10cSrcweir pStateSetHelper = new ::utl::AccessibleStateSetHelper; 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir if( isAlive() ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir // SHOWING done with mxParent 437*cdf0e10cSrcweir if( implIsShowing() ) 438*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 439*cdf0e10cSrcweir // BrowseBox fills StateSet with states depending on object type 440*cdf0e10cSrcweir mpBrowseBox->FillAccessibleStateSet( *pStateSetHelper, getType() ); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir else 443*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir return pStateSetHelper; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir // internal helper methods ---------------------------------------------------- 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir sal_Bool AccessibleBrowseBoxBase::isAlive() const 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir return !rBHelper.bDisposed && !rBHelper.bInDispose && mpBrowseBox; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir void AccessibleBrowseBoxBase::ensureIsAlive() const 456*cdf0e10cSrcweir throw ( lang::DisposedException ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir if( !isAlive() ) 459*cdf0e10cSrcweir throw lang::DisposedException(); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir Rectangle AccessibleBrowseBoxBase::getBoundingBox() 463*cdf0e10cSrcweir throw ( lang::DisposedException ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 466*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 467*cdf0e10cSrcweir ensureIsAlive(); 468*cdf0e10cSrcweir Rectangle aRect = implGetBoundingBox(); 469*cdf0e10cSrcweir if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() ) 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir DBG_ERRORFILE( "shit" ); 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir return aRect; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir Rectangle AccessibleBrowseBoxBase::getBoundingBoxOnScreen() 477*cdf0e10cSrcweir throw ( lang::DisposedException ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 480*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 481*cdf0e10cSrcweir ensureIsAlive(); 482*cdf0e10cSrcweir Rectangle aRect = implGetBoundingBoxOnScreen(); 483*cdf0e10cSrcweir if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir DBG_ERRORFILE( "shit" ); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir return aRect; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir void AccessibleBrowseBoxBase::commitEvent( 491*cdf0e10cSrcweir sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() ); 494*cdf0e10cSrcweir if ( !getClientId( ) ) 495*cdf0e10cSrcweir // if we don't have a client id for the notifier, then we don't have listeners, then 496*cdf0e10cSrcweir // we don't need to notify anything 497*cdf0e10cSrcweir return; 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir // build an event object 500*cdf0e10cSrcweir AccessibleEventObject aEvent; 501*cdf0e10cSrcweir aEvent.Source = *this; 502*cdf0e10cSrcweir aEvent.EventId = _nEventId; 503*cdf0e10cSrcweir aEvent.OldValue = _rOldValue; 504*cdf0e10cSrcweir aEvent.NewValue = _rNewValue; 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir // let the notifier handle this event 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir AccessibleEventNotifier::addEvent( getClientId( ), aEvent ); 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir void AccessibleBrowseBoxBase::implCreateUuid( Sequence< sal_Int8 >& rId ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir if( !rId.hasElements() ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir rId.realloc( 16 ); 517*cdf0e10cSrcweir rtl_createUuid( reinterpret_cast< sal_uInt8* >( rId.getArray() ), 0, sal_True ); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 521*cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleBrowseBoxBase::getAccessibleRole() 522*cdf0e10cSrcweir throw ( uno::RuntimeException ) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir ensureIsAlive(); 525*cdf0e10cSrcweir sal_Int16 nRole = AccessibleRole::UNKNOWN; 526*cdf0e10cSrcweir switch ( meObjType ) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir case BBTYPE_ROWHEADERCELL: 529*cdf0e10cSrcweir nRole = AccessibleRole::ROW_HEADER; 530*cdf0e10cSrcweir break; 531*cdf0e10cSrcweir case BBTYPE_COLUMNHEADERCELL: 532*cdf0e10cSrcweir nRole = AccessibleRole::COLUMN_HEADER; 533*cdf0e10cSrcweir break; 534*cdf0e10cSrcweir case BBTYPE_COLUMNHEADERBAR: 535*cdf0e10cSrcweir case BBTYPE_ROWHEADERBAR: 536*cdf0e10cSrcweir case BBTYPE_TABLE: 537*cdf0e10cSrcweir nRole = AccessibleRole::TABLE; 538*cdf0e10cSrcweir break; 539*cdf0e10cSrcweir case BBTYPE_TABLECELL: 540*cdf0e10cSrcweir nRole = AccessibleRole::TABLE_CELL; 541*cdf0e10cSrcweir break; 542*cdf0e10cSrcweir case BBTYPE_BROWSEBOX: 543*cdf0e10cSrcweir nRole = AccessibleRole::PANEL; 544*cdf0e10cSrcweir break; 545*cdf0e10cSrcweir case BBTYPE_CHECKBOXCELL: 546*cdf0e10cSrcweir nRole = AccessibleRole::CHECK_BOX; 547*cdf0e10cSrcweir break; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir return nRole; 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 552*cdf0e10cSrcweir Any SAL_CALL AccessibleBrowseBoxBase::getAccessibleKeyBinding() 553*cdf0e10cSrcweir throw ( uno::RuntimeException ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir return Any(); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 558*cdf0e10cSrcweir Reference<XAccessible > SAL_CALL AccessibleBrowseBoxBase::getAccessibleAtPoint( const ::com::sun::star::awt::Point& ) 559*cdf0e10cSrcweir throw ( uno::RuntimeException ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir return NULL; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 564*cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir m_xFocusWindow = NULL; 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 569*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxBase::getForeground( ) throw (::com::sun::star::uno::RuntimeException) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 572*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 573*cdf0e10cSrcweir ensureIsAlive(); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir sal_Int32 nColor = 0; 576*cdf0e10cSrcweir Window* pInst = mpBrowseBox->GetWindowInstance(); 577*cdf0e10cSrcweir if ( pInst ) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir if ( pInst->IsControlForeground() ) 580*cdf0e10cSrcweir nColor = pInst->GetControlForeground().GetColor(); 581*cdf0e10cSrcweir else 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir Font aFont; 584*cdf0e10cSrcweir if ( pInst->IsControlFont() ) 585*cdf0e10cSrcweir aFont = pInst->GetControlFont(); 586*cdf0e10cSrcweir else 587*cdf0e10cSrcweir aFont = pInst->GetFont(); 588*cdf0e10cSrcweir nColor = aFont.GetColor().GetColor(); 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir return nColor; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 595*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxBase::getBackground( ) throw (::com::sun::star::uno::RuntimeException) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir BBSolarGuard aSolarGuard; 598*cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() ); 599*cdf0e10cSrcweir ensureIsAlive(); 600*cdf0e10cSrcweir sal_Int32 nColor = 0; 601*cdf0e10cSrcweir Window* pInst = mpBrowseBox->GetWindowInstance(); 602*cdf0e10cSrcweir if ( pInst ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir if ( pInst->IsControlBackground() ) 605*cdf0e10cSrcweir nColor = pInst->GetControlBackground().GetColor(); 606*cdf0e10cSrcweir else 607*cdf0e10cSrcweir nColor = pInst->GetBackground().GetColor().GetColor(); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir return nColor; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir // ============================================================================ 614*cdf0e10cSrcweir DBG_NAME( BrowseBoxAccessibleElement ) 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir // XInterface ----------------------------------------------------------------- 617*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( BrowseBoxAccessibleElement, AccessibleBrowseBoxBase, BrowseBoxAccessibleElement_Base ) 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir // XTypeProvider -------------------------------------------------------------- 620*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( BrowseBoxAccessibleElement, AccessibleBrowseBoxBase, BrowseBoxAccessibleElement_Base ) 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir // XAccessible ---------------------------------------------------------------- 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL BrowseBoxAccessibleElement::getAccessibleContext() throw ( uno::RuntimeException ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir ensureIsAlive(); 627*cdf0e10cSrcweir return this; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 631*cdf0e10cSrcweir BrowseBoxAccessibleElement::BrowseBoxAccessibleElement( const Reference< XAccessible >& rxParent, IAccessibleTableProvider& rBrowseBox, 632*cdf0e10cSrcweir const Reference< awt::XWindow >& _xFocusWindow, AccessibleBrowseBoxObjType eObjType ) 633*cdf0e10cSrcweir :AccessibleBrowseBoxBase( rxParent, rBrowseBox, _xFocusWindow, eObjType ) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir DBG_CTOR( BrowseBoxAccessibleElement, NULL ); 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 639*cdf0e10cSrcweir BrowseBoxAccessibleElement::BrowseBoxAccessibleElement( const Reference< XAccessible >& rxParent, IAccessibleTableProvider& rBrowseBox, 640*cdf0e10cSrcweir const Reference< awt::XWindow >& _xFocusWindow, AccessibleBrowseBoxObjType eObjType, 641*cdf0e10cSrcweir const ::rtl::OUString& rName, const ::rtl::OUString& rDescription ) 642*cdf0e10cSrcweir :AccessibleBrowseBoxBase( rxParent, rBrowseBox, _xFocusWindow, eObjType, rName, rDescription ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir DBG_CTOR( BrowseBoxAccessibleElement, NULL ); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 648*cdf0e10cSrcweir BrowseBoxAccessibleElement::~BrowseBoxAccessibleElement( ) 649*cdf0e10cSrcweir { 650*cdf0e10cSrcweir DBG_DTOR( BrowseBoxAccessibleElement, NULL ); 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir // ============================================================================ 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir } // namespace accessibility 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir // ============================================================================ 658*cdf0e10cSrcweir 659