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_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "svxrectctaccessiblecontext.hxx" 33*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 35*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 39*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 40*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 41*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 42*cdf0e10cSrcweir #include <vcl/svapp.hxx> 43*cdf0e10cSrcweir #include <osl/mutex.hxx> 44*cdf0e10cSrcweir #include <rtl/uuid.h> 45*cdf0e10cSrcweir #include <tools/debug.hxx> 46*cdf0e10cSrcweir #include <tools/gen.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <svx/dialogs.hrc> 49*cdf0e10cSrcweir #include "accessibility.hrc" 50*cdf0e10cSrcweir #include <svx/dlgctrl.hxx> 51*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 52*cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir using namespace ::cppu; 56*cdf0e10cSrcweir using namespace ::osl; 57*cdf0e10cSrcweir using namespace ::com::sun::star; 58*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 59*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #define MAX_NUM_OF_CHILDS 9 63*cdf0e10cSrcweir #define NOCHILDSELECTED -1 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir DBG_NAME( SvxRectCtlAccessibleContext ) 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir //===== internal ============================================================ 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir namespace 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir struct ChildIndexToPointData 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir short nResIdName; 76*cdf0e10cSrcweir short nResIdDescr; 77*cdf0e10cSrcweir RECT_POINT ePoint; 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir static const ChildIndexToPointData* IndexToPoint( long nIndex, sal_Bool bAngleControl ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir DBG_ASSERT( nIndex < ( bAngleControl? 8 : 9 ) && nIndex >= 0, "-IndexToPoint(): invalid child index! You have been warned..." ); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // angles are counted reverse counter clock wise 87*cdf0e10cSrcweir static const ChildIndexToPointData pAngleData[] = 88*cdf0e10cSrcweir { // index 89*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A000, RID_SVXSTR_RECTCTL_ACC_CHLD_A000, RP_RM }, // 0 90*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A045, RID_SVXSTR_RECTCTL_ACC_CHLD_A045, RP_RT }, // 1 91*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A090, RID_SVXSTR_RECTCTL_ACC_CHLD_A090, RP_MT }, // 2 92*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A135, RID_SVXSTR_RECTCTL_ACC_CHLD_A135, RP_LT }, // 3 93*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A180, RID_SVXSTR_RECTCTL_ACC_CHLD_A180, RP_LM }, // 4 94*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A225, RID_SVXSTR_RECTCTL_ACC_CHLD_A225, RP_LB }, // 5 95*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A270, RID_SVXSTR_RECTCTL_ACC_CHLD_A270, RP_MB }, // 6 96*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_A315, RID_SVXSTR_RECTCTL_ACC_CHLD_A315, RP_RB } // 7 97*cdf0e10cSrcweir }; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir // corners are counted from left to right and top to bottom 100*cdf0e10cSrcweir static const ChildIndexToPointData pCornerData[] = 101*cdf0e10cSrcweir { // index 102*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_LT, RID_SVXSTR_RECTCTL_ACC_CHLD_LT, RP_LT }, // 0 103*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_MT, RID_SVXSTR_RECTCTL_ACC_CHLD_MT, RP_MT }, // 1 104*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_RT, RID_SVXSTR_RECTCTL_ACC_CHLD_RT, RP_RT }, // 2 105*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_LM, RID_SVXSTR_RECTCTL_ACC_CHLD_LM, RP_LM }, // 3 106*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_MM, RID_SVXSTR_RECTCTL_ACC_CHLD_MM, RP_MM }, // 4 107*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_RM, RID_SVXSTR_RECTCTL_ACC_CHLD_RM, RP_RM }, // 5 108*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_LB, RID_SVXSTR_RECTCTL_ACC_CHLD_LB, RP_LB }, // 6 109*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_MB, RID_SVXSTR_RECTCTL_ACC_CHLD_MB, RP_MB }, // 7 110*cdf0e10cSrcweir { RID_SVXSTR_RECTCTL_ACC_CHLD_RB, RID_SVXSTR_RECTCTL_ACC_CHLD_RB, RP_RB } // 8 111*cdf0e10cSrcweir }; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir return ( bAngleControl? pAngleData : pCornerData ) + nIndex; 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir static long PointToIndex( RECT_POINT ePoint, sal_Bool bAngleControl ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir long nRet( (long) ePoint ); 120*cdf0e10cSrcweir if( bAngleControl ) 121*cdf0e10cSrcweir { // angle control 122*cdf0e10cSrcweir // angles are counted reverse counter clock wise 123*cdf0e10cSrcweir switch( ePoint ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir case RP_LT: nRet = 3; break; 126*cdf0e10cSrcweir case RP_MT: nRet = 2; break; 127*cdf0e10cSrcweir case RP_RT: nRet = 1; break; 128*cdf0e10cSrcweir case RP_LM: nRet = 4; break; 129*cdf0e10cSrcweir case RP_MM: nRet = NOCHILDSELECTED; break; 130*cdf0e10cSrcweir case RP_RM: nRet = 0; break; 131*cdf0e10cSrcweir case RP_LB: nRet = 5; break; 132*cdf0e10cSrcweir case RP_MB: nRet = 6; break; 133*cdf0e10cSrcweir case RP_RB: nRet = 7; break; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir else 137*cdf0e10cSrcweir { // corner control 138*cdf0e10cSrcweir // corners are counted from left to right and top to bottom 139*cdf0e10cSrcweir DBG_ASSERT( RP_LT == 0 && RP_MT == 1 && RP_RT == 2 && RP_LM == 3 && RP_MM == 4 && RP_RM == 5 && 140*cdf0e10cSrcweir RP_LB == 6 && RP_MB == 7 && RP_RB == 8, "*PointToIndex(): unexpected enum value!" ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir nRet = ( long ) ePoint; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir return nRet; 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir SvxRectCtlAccessibleContext::SvxRectCtlAccessibleContext( 150*cdf0e10cSrcweir const Reference< XAccessible >& rxParent, 151*cdf0e10cSrcweir SvxRectCtl& rRepr, 152*cdf0e10cSrcweir const ::rtl::OUString* pName, 153*cdf0e10cSrcweir const ::rtl::OUString* pDesc ) : 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir SvxRectCtlAccessibleContext_Base( m_aMutex ), 156*cdf0e10cSrcweir mxParent( rxParent ), 157*cdf0e10cSrcweir mpRepr( &rRepr ), 158*cdf0e10cSrcweir mpChilds( NULL ), 159*cdf0e10cSrcweir mnClientId( 0 ), 160*cdf0e10cSrcweir mnSelectedChild( NOCHILDSELECTED ), 161*cdf0e10cSrcweir mbAngleMode( rRepr.GetNumOfChilds() == 8 ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir DBG_CTOR( SvxRectCtlAccessibleContext, NULL ); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if( pName ) 166*cdf0e10cSrcweir msName = *pName; 167*cdf0e10cSrcweir else 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 170*cdf0e10cSrcweir msName = SVX_RESSTR( mbAngleMode? RID_SVXSTR_RECTCTL_ACC_ANGL_NAME : RID_SVXSTR_RECTCTL_ACC_CORN_NAME ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if( pDesc ) 174*cdf0e10cSrcweir msDescription = *pDesc; 175*cdf0e10cSrcweir else 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 178*cdf0e10cSrcweir msDescription = SVX_RESSTR( mbAngleMode? RID_SVXSTR_RECTCTL_ACC_ANGL_DESCR : RID_SVXSTR_RECTCTL_ACC_CORN_DESCR ); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir mpChilds = new SvxRectCtlChildAccessibleContext*[ MAX_NUM_OF_CHILDS ]; 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext** p = mpChilds; 184*cdf0e10cSrcweir for( int i = MAX_NUM_OF_CHILDS ; i ; --i, ++p ) 185*cdf0e10cSrcweir *p = NULL; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir SvxRectCtlAccessibleContext::~SvxRectCtlAccessibleContext() 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir DBG_DTOR( SvxRectCtlAccessibleContext, NULL ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if( IsAlive() ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 196*cdf0e10cSrcweir dispose(); // set mpRepr = NULL & release all childs 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir //===== XAccessible ========================================================= 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleContext( void ) throw( RuntimeException ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir return this; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir //===== XAccessibleComponent ================================================ 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir // no guard -> done in getBounds() 212*cdf0e10cSrcweir // return GetBoundingBox().IsInside( VCLPoint( rPoint ) ); 213*cdf0e10cSrcweir return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) throw( RuntimeException ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir Reference< XAccessible > xRet; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir long nChild = PointToIndex( mpRepr->GetApproxRPFromPixPt( rPoint ), mbAngleMode ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir if( nChild != NOCHILDSELECTED ) 227*cdf0e10cSrcweir xRet = getAccessibleChild( nChild ); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir return xRet; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir awt::Rectangle SAL_CALL SvxRectCtlAccessibleContext::getBounds() throw( RuntimeException ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir // no guard -> done in GetBoundingBox() 235*cdf0e10cSrcweir return AWTRectangle( GetBoundingBox() ); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocation() throw( RuntimeException ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir // no guard -> done in GetBoundingBox() 241*cdf0e10cSrcweir return AWTPoint( GetBoundingBox().TopLeft() ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocationOnScreen() throw( RuntimeException ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir // no guard -> done in GetBoundingBoxOnScreen() 247*cdf0e10cSrcweir return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir awt::Size SAL_CALL SvxRectCtlAccessibleContext::getSize() throw( RuntimeException ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir // no guard -> done in GetBoundingBox() 253*cdf0e10cSrcweir return AWTSize( GetBoundingBox().GetSize() ); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isShowing() throw( RuntimeException ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir return sal_True; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isVisible() throw( RuntimeException ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir return mpRepr->IsVisible(); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isFocusTraversable() throw( RuntimeException ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir return sal_True; 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir //===== XAccessibleContext ================================================== 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir return mpRepr->GetNumOfChilds(); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex ) 287*cdf0e10cSrcweir throw( RuntimeException, lang::IndexOutOfBoundsException ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir checkChildIndex( nIndex ); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir Reference< XAccessible > xChild = mpChilds[ nIndex ]; 292*cdf0e10cSrcweir if( !xChild.is() ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir xChild = mpChilds[ nIndex ]; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if( !xChild.is() ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir const ChildIndexToPointData* p = IndexToPoint( nIndex, mbAngleMode ); 305*cdf0e10cSrcweir UniString tmp = SVX_RESSTR( p->nResIdName ); 306*cdf0e10cSrcweir ::rtl::OUString aName( tmp ); 307*cdf0e10cSrcweir tmp = SVX_RESSTR( p->nResIdDescr ); 308*cdf0e10cSrcweir ::rtl::OUString aDescr( tmp ); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir Rectangle aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) ); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir Rectangle aBoundingBoxOnScreen( mpRepr->OutputToScreenPixel( aFocusRect.TopLeft() ), aFocusRect.GetSize() ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext* pChild = new SvxRectCtlChildAccessibleContext( 315*cdf0e10cSrcweir this, *mpRepr, aName, aDescr, aFocusRect, nIndex ); 316*cdf0e10cSrcweir xChild = mpChilds[ nIndex ] = pChild; 317*cdf0e10cSrcweir pChild->acquire(); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir // set actual state 320*cdf0e10cSrcweir if( mnSelectedChild == nIndex ) 321*cdf0e10cSrcweir pChild->setStateChecked( sal_True ); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir return xChild; 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleParent( void ) throw( RuntimeException ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir return mxParent; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 336*cdf0e10cSrcweir // Use a simple but slow solution for now. Optimize later. 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir // Iterate over all the parent's children and search for this object. 339*cdf0e10cSrcweir if( mxParent.is() ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 342*cdf0e10cSrcweir if( xParentContext.is() ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); 345*cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < nChildCount ; ++i ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); 348*cdf0e10cSrcweir if( xChild.get() == ( XAccessible* ) this ) 349*cdf0e10cSrcweir return i; 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir // Return -1 to indicate that this object's parent does not know about the 355*cdf0e10cSrcweir // object. 356*cdf0e10cSrcweir return -1; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir sal_Int16 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRole( void ) throw( RuntimeException ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir return AccessibleRole::PANEL; 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 367*cdf0e10cSrcweir return msDescription; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleName( void ) throw( RuntimeException ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 373*cdf0e10cSrcweir return msName; 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir /** Return empty reference to indicate that the relation set is not 377*cdf0e10cSrcweir supported. 378*cdf0e10cSrcweir */ 379*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir return Reference< XAccessibleRelationSet >(); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 387*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir if( IsAlive() ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir // pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 392*cdf0e10cSrcweir // pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 393*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); 394*cdf0e10cSrcweir if( mpRepr->HasFocus() ) 395*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::FOCUSED ); 396*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::OPAQUE ); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir if( isShowing() ) 399*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir if( isVisible() ) 402*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir else 405*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir return pStateSetHelper; 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir lang::Locale SAL_CALL SvxRectCtlAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 413*cdf0e10cSrcweir if( mxParent.is() ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 416*cdf0e10cSrcweir if( xParentContext.is() ) 417*cdf0e10cSrcweir return xParentContext->getLocale(); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // No parent. Therefore throw exception to indicate this cluelessness. 421*cdf0e10cSrcweir throw IllegalAccessibleComponentStateException(); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener ) 425*cdf0e10cSrcweir throw( RuntimeException ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir if (xListener.is()) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 430*cdf0e10cSrcweir if (!mnClientId) 431*cdf0e10cSrcweir mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); 432*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) 437*cdf0e10cSrcweir throw( RuntimeException ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir if (xListener.is()) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); 444*cdf0e10cSrcweir if ( !nListenerCount ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir // no listeners anymore 447*cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 448*cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls 449*cdf0e10cSrcweir // NotifyAccessibleEvent, again 450*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); 451*cdf0e10cSrcweir mnClientId = 0; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& xListener ) 457*cdf0e10cSrcweir throw( RuntimeException ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir if( xListener.is() ) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr ); 466*cdf0e10cSrcweir if( xWindow.is() ) 467*cdf0e10cSrcweir xWindow->addFocusListener( xListener ); 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& xListener ) 472*cdf0e10cSrcweir throw (RuntimeException) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir if( xListener.is() ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr ); 481*cdf0e10cSrcweir if( xWindow.is() ) 482*cdf0e10cSrcweir xWindow->removeFocusListener( xListener ); 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::grabFocus() throw( RuntimeException ) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 489*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir mpRepr->GrabFocus(); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir Any SAL_CALL SvxRectCtlAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir // here is no implementation, because here are no KeyBindings for every object 499*cdf0e10cSrcweir return Any(); 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir sal_Int32 SvxRectCtlAccessibleContext::getForeground( ) 503*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 506*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 507*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir return mpRepr->GetControlForeground().GetColor(); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir sal_Int32 SvxRectCtlAccessibleContext::getBackground( ) 512*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 515*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 516*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir return mpRepr->GetControlBackground().GetColor(); 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir //===== XServiceInfo ======================================================== 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getImplementationName( void ) throw( RuntimeException ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxRectCtlAccessibleContext" ) ); 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlAccessibleContext::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 531*cdf0e10cSrcweir // Iterate over all supported service names and return true if on of them 532*cdf0e10cSrcweir // matches the given name. 533*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupportedServices( getSupportedServiceNames() ); 534*cdf0e10cSrcweir int nLength = aSupportedServices.getLength(); 535*cdf0e10cSrcweir const ::rtl::OUString* pStr = aSupportedServices.getConstArray(); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir for( int i = nLength ; i ; --i, ++pStr ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir if( sServiceName == *pStr ) 540*cdf0e10cSrcweir return sal_True; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir return sal_False; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SvxRectCtlAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException ) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); 549*cdf0e10cSrcweir return Sequence< ::rtl::OUString >( &sServiceName, 1 ); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir //===== XTypeProvider ======================================================= 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL SvxRectCtlAccessibleContext::getImplementationId( void ) throw( RuntimeException ) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir return getUniqueId(); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir //===== XAccessibleSelection ============================================= 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir checkChildIndex( nIndex ); 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir const ChildIndexToPointData* pData = IndexToPoint( nIndex, mbAngleMode ); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir DBG_ASSERT( pData, 574*cdf0e10cSrcweir "SvxRectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..." ); 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir // this does all wich is needed, including the change of the child's state! 577*cdf0e10cSrcweir mpRepr->SetActualRP( pData->ePoint ); 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir checkChildIndex( nIndex ); 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir return nIndex == mnSelectedChild; 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::clearAccessibleSelection() throw( RuntimeException ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir DBG_ASSERT( sal_False, "SvxRectCtlAccessibleContext::clearAccessibleSelection() is not possible!" ); 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException ) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir // guard in selectAccessibleChild()! 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir selectAccessibleChild( 0 ); // default per definition 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException ) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir return mnSelectedChild == NOCHILDSELECTED? 0 : 1; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex ) 609*cdf0e10cSrcweir throw( lang::IndexOutOfBoundsException, RuntimeException ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir checkChildIndexOnSelection( nIndex ); 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir return getAccessibleChild( mnSelectedChild ); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::deselectAccessibleChild( sal_Int32 /*nIndex*/ ) throw( lang::IndexOutOfBoundsException, RuntimeException ) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir ::rtl::OUString aMessage( RTL_CONSTASCII_USTRINGPARAM( "deselectAccessibleChild is not possible in this context" ) ); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir DBG_ASSERT( sal_False, "SvxRectCtlAccessibleContext::deselectAccessibleChild() is not possible!" ); 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException( aMessage, *this ); // never possible 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir //===== internals ======================================================== 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::checkChildIndex( long nIndex ) throw( lang::IndexOutOfBoundsException ) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir if( nIndex < 0 || nIndex >= getAccessibleChildCount() ) 632*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir if( nIndex || mnSelectedChild == NOCHILDSELECTED ) 638*cdf0e10cSrcweir // in our case only for the first (0) _selected_ child this is a valid request 639*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::selectChild( long nNew ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 645*cdf0e10cSrcweir if( nNew != mnSelectedChild ) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir long nNumOfChilds = getAccessibleChildCount(); 648*cdf0e10cSrcweir if( nNew < nNumOfChilds ) 649*cdf0e10cSrcweir { // valid index 650*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext* pChild; 651*cdf0e10cSrcweir if( mnSelectedChild != NOCHILDSELECTED ) 652*cdf0e10cSrcweir { // deselect old selected child if one is selected 653*cdf0e10cSrcweir pChild = mpChilds[ mnSelectedChild ]; 654*cdf0e10cSrcweir if( pChild ) 655*cdf0e10cSrcweir pChild->setStateChecked( sal_False ); 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir // select new child 659*cdf0e10cSrcweir mnSelectedChild = nNew; 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir if( nNew != NOCHILDSELECTED ) 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir pChild = mpChilds[ nNew ]; 664*cdf0e10cSrcweir if( pChild ) 665*cdf0e10cSrcweir pChild->setStateChecked( sal_True ); 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir else 669*cdf0e10cSrcweir mnSelectedChild = NOCHILDSELECTED; 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::selectChild( RECT_POINT eButton ) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir // no guard -> is done in next selectChild 676*cdf0e10cSrcweir selectChild( PointToIndex( eButton, mbAngleMode ) ); 677*cdf0e10cSrcweir } 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::setName( const ::rtl::OUString& rName ) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir Any aPreVal, aPostVal; 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir aPreVal <<= msName; 686*cdf0e10cSrcweir aPostVal <<= rName; 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir msName = rName; 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir const Reference< XInterface > xSource( *this ); 692*cdf0e10cSrcweir CommitChange( AccessibleEventObject( xSource, AccessibleEventId::NAME_CHANGED, aPreVal, aPostVal ) ); 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::setDescription( const ::rtl::OUString& rDescr ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir Any aPreVal, aPostVal; 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir aPreVal <<= msDescription; 702*cdf0e10cSrcweir aPostVal <<= rDescr; 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir msDescription = rDescr; 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir const Reference< XInterface > xSource( *this ); 708*cdf0e10cSrcweir CommitChange( AccessibleEventObject( xSource, AccessibleEventId::DESCRIPTION_CHANGED, aPreVal, aPostVal ) ); 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::CommitChange( const AccessibleEventObject& rEvent ) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir if (mnClientId) 714*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir void SAL_CALL SvxRectCtlAccessibleContext::disposing() 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir if( !rBHelper.bDisposed ) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 723*cdf0e10cSrcweir mpRepr = NULL; // object dies with representation 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext** p = mpChilds; 726*cdf0e10cSrcweir for( int i = MAX_NUM_OF_CHILDS ; i ; --i, ++p ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext* pChild = *p; 729*cdf0e10cSrcweir if( pChild ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir pChild->dispose(); 732*cdf0e10cSrcweir pChild->release(); 733*cdf0e10cSrcweir *p = NULL; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir delete[] mpChilds; 738*cdf0e10cSrcweir mpChilds = NULL; 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir // Send a disposing to all listeners. 745*cdf0e10cSrcweir if ( mnClientId ) 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); 748*cdf0e10cSrcweir mnClientId = 0; 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir mxParent = Reference< XAccessible >(); 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir Rectangle SvxRectCtlAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException ) 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 759*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir return Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() ); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir Rectangle SvxRectCtlAccessibleContext::GetBoundingBox( void ) throw( RuntimeException ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 769*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() ); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir Sequence< sal_Int8 > SvxRectCtlAccessibleContext::getUniqueId( void ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir static OImplementationId* pId = 0; 779*cdf0e10cSrcweir if( !pId ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 782*cdf0e10cSrcweir if( !pId) 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir static OImplementationId aId; 785*cdf0e10cSrcweir pId = &aId; 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir } 788*cdf0e10cSrcweir return pId->getImplementationId(); 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir void SvxRectCtlAccessibleContext::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir if( IsNotAlive() ) 794*cdf0e10cSrcweir throw lang::DisposedException(); 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir // ------------------------------------------------------------------------------------------------- 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir DBG_NAME( SvxRectCtlChildAccessibleContext ) 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext::SvxRectCtlChildAccessibleContext( 804*cdf0e10cSrcweir const Reference<XAccessible>& rxParent, 805*cdf0e10cSrcweir const Window& rParentWindow, 806*cdf0e10cSrcweir const ::rtl::OUString& rName, 807*cdf0e10cSrcweir const ::rtl::OUString& rDescription, 808*cdf0e10cSrcweir const Rectangle& rBoundingBox, 809*cdf0e10cSrcweir long nIndexInParent ) : 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext_Base( maMutex ), 812*cdf0e10cSrcweir msDescription( rDescription ), 813*cdf0e10cSrcweir msName( rName ), 814*cdf0e10cSrcweir mxParent(rxParent), 815*cdf0e10cSrcweir mpBoundingBox( new Rectangle( rBoundingBox ) ), 816*cdf0e10cSrcweir mrParentWindow( rParentWindow ), 817*cdf0e10cSrcweir mnClientId( 0 ), 818*cdf0e10cSrcweir mnIndexInParent( nIndexInParent ), 819*cdf0e10cSrcweir mbIsChecked( sal_False ) 820*cdf0e10cSrcweir { 821*cdf0e10cSrcweir DBG_CTOR( SvxRectCtlChildAccessibleContext, NULL ); 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir SvxRectCtlChildAccessibleContext::~SvxRectCtlChildAccessibleContext() 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir DBG_DTOR( SvxRectCtlChildAccessibleContext, NULL ); 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir if( IsAlive() ) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 832*cdf0e10cSrcweir dispose(); // set mpRepr = NULL & release all childs 833*cdf0e10cSrcweir } 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir //===== XAccessible ========================================================= 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir Reference< XAccessibleContext> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleContext( void ) throw( RuntimeException ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir return this; 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir //===== XAccessibleComponent ================================================ 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException ) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir // no guard -> done in getBounds() 848*cdf0e10cSrcweir // return GetBoundingBox().IsInside( VCLPoint( rPoint ) ); 849*cdf0e10cSrcweir return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 850*cdf0e10cSrcweir } 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleAtPoint( const awt::Point& /*rPoint*/ ) throw( RuntimeException ) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir return Reference< XAccessible >(); 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir awt::Rectangle SAL_CALL SvxRectCtlChildAccessibleContext::getBounds() throw( RuntimeException ) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir // no guard -> done in getBoundingBox() 860*cdf0e10cSrcweir return AWTRectangle( GetBoundingBox() ); 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocation() throw( RuntimeException ) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir // no guard -> done in getBoundingBox() 866*cdf0e10cSrcweir return AWTPoint( GetBoundingBox().TopLeft() ); 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocationOnScreen() throw( RuntimeException ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir // no guard -> done in getBoundingBoxOnScreen() 872*cdf0e10cSrcweir return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir awt::Size SAL_CALL SvxRectCtlChildAccessibleContext::getSize() throw( RuntimeException ) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir // no guard -> done in getBoundingBox() 878*cdf0e10cSrcweir return AWTSize( GetBoundingBox().GetSize() ); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isShowing() throw( RuntimeException ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir return sal_True; 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isVisible() throw( RuntimeException ) 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir return mxParent.is()? ( static_cast< SvxRectCtlAccessibleContext* >( mxParent.get() ) )->isVisible() : sal_False; 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir 895*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isFocusTraversable() throw( RuntimeException ) 896*cdf0e10cSrcweir { 897*cdf0e10cSrcweir return sal_False; 898*cdf0e10cSrcweir } 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir void SAL_CALL SvxRectCtlChildAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& /*xListener*/ ) 901*cdf0e10cSrcweir throw( RuntimeException ) 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir OSL_ENSURE( false, "SvxRectCtlChildAccessibleContext::addFocusListener: not implemented" ); 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir void SAL_CALL SvxRectCtlChildAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& /*xListener*/ ) 907*cdf0e10cSrcweir throw (RuntimeException) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir OSL_ENSURE( false, "SvxRectCtlChildAccessibleContext::removeFocusListener: not implemented" ); 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir void SAL_CALL SvxRectCtlChildAccessibleContext::grabFocus() throw( RuntimeException ) 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir Any SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException ) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir // here is no implementation, because here are no KeyBindings for every object 919*cdf0e10cSrcweir return Any(); 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir sal_Int32 SvxRectCtlChildAccessibleContext::getForeground( ) 922*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 923*cdf0e10cSrcweir { 924*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 925*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 926*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 927*cdf0e10cSrcweir return mrParentWindow.GetControlForeground().GetColor(); 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir sal_Int32 SvxRectCtlChildAccessibleContext::getBackground( ) 930*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 933*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 936*cdf0e10cSrcweir return mrParentWindow.GetControlBackground().GetColor(); 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir //===== XAccessibleContext ================================================== 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException ) 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir return 0; 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChild( sal_Int32 /*nIndex*/ ) throw ( RuntimeException, lang::IndexOutOfBoundsException ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleParent( void ) throw( RuntimeException ) 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir return mxParent; 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException ) 957*cdf0e10cSrcweir { 958*cdf0e10cSrcweir return mnIndexInParent; 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir sal_Int16 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRole( void ) throw( RuntimeException ) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir return AccessibleRole::RADIO_BUTTON; 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException ) 967*cdf0e10cSrcweir { 968*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 969*cdf0e10cSrcweir return msDescription; 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleName( void ) throw( RuntimeException ) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 975*cdf0e10cSrcweir return msName; 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir /** Return empty reference to indicate that the relation set is not 979*cdf0e10cSrcweir supported. 980*cdf0e10cSrcweir */ 981*cdf0e10cSrcweir Reference<XAccessibleRelationSet> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir return Reference< XAccessibleRelationSet >(); 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 989*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir if( IsAlive() ) 992*cdf0e10cSrcweir { 993*cdf0e10cSrcweir if( mbIsChecked ) 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::CHECKED ); 996*cdf0e10cSrcweir // pStateSetHelper->AddState( AccessibleStateType::SELECTED ); 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 1000*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 1001*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::OPAQUE ); 1002*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 1003*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 1004*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 1005*cdf0e10cSrcweir } 1006*cdf0e10cSrcweir else 1007*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir return pStateSetHelper; 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir lang::Locale SAL_CALL SvxRectCtlChildAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException ) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1015*cdf0e10cSrcweir if( mxParent.is() ) 1016*cdf0e10cSrcweir { 1017*cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 1018*cdf0e10cSrcweir if( xParentContext.is() ) 1019*cdf0e10cSrcweir return xParentContext->getLocale(); 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir // No locale and no parent. Therefore throw exception to indicate this 1023*cdf0e10cSrcweir // cluelessness. 1024*cdf0e10cSrcweir throw IllegalAccessibleComponentStateException(); 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir void SAL_CALL SvxRectCtlChildAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener ) 1028*cdf0e10cSrcweir throw( RuntimeException ) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir if (xListener.is()) 1031*cdf0e10cSrcweir { 1032*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1033*cdf0e10cSrcweir if (!mnClientId) 1034*cdf0e10cSrcweir mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); 1035*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir void SAL_CALL SvxRectCtlChildAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) 1043*cdf0e10cSrcweir throw( RuntimeException ) 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir if (xListener.is()) 1046*cdf0e10cSrcweir { 1047*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); 1050*cdf0e10cSrcweir if ( !nListenerCount ) 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir // no listeners anymore 1053*cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 1054*cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls 1055*cdf0e10cSrcweir // NotifyAccessibleEvent, again 1056*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); 1057*cdf0e10cSrcweir mnClientId = 0; 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir } 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir //===== XAccessibleValue ================================================ 1063*cdf0e10cSrcweir 1064*cdf0e10cSrcweir Any SAL_CALL SvxRectCtlChildAccessibleContext::getCurrentValue() throw( RuntimeException ) 1065*cdf0e10cSrcweir { 1066*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir Any aRet; 1069*cdf0e10cSrcweir aRet <<= ( mbIsChecked? 1.0 : 0.0 ); 1070*cdf0e10cSrcweir return aRet; 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::setCurrentValue( const Any& /*aNumber*/ ) throw( RuntimeException ) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir return sal_False; 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir 1078*cdf0e10cSrcweir Any SAL_CALL SvxRectCtlChildAccessibleContext::getMaximumValue() throw( RuntimeException ) 1079*cdf0e10cSrcweir { 1080*cdf0e10cSrcweir Any aRet; 1081*cdf0e10cSrcweir aRet <<= 1.0; 1082*cdf0e10cSrcweir return aRet; 1083*cdf0e10cSrcweir } 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir Any SAL_CALL SvxRectCtlChildAccessibleContext::getMinimumValue() throw( RuntimeException ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir Any aRet; 1088*cdf0e10cSrcweir aRet <<= 0.0; 1089*cdf0e10cSrcweir return aRet; 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir //===== XServiceInfo ======================================================== 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationName( void ) throw( RuntimeException ) 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxRectCtlChildAccessibleContext" ) ); 1097*cdf0e10cSrcweir } 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException ) 1100*cdf0e10cSrcweir { 1101*cdf0e10cSrcweir // Iterate over all supported service names and return true if on of them 1102*cdf0e10cSrcweir // matches the given name. 1103*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1104*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupportedServices ( getSupportedServiceNames() ); 1105*cdf0e10cSrcweir int nLength = aSupportedServices.getLength(); 1106*cdf0e10cSrcweir for( int i = 0 ; i < nLength; ++i ) 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir if( sServiceName == aSupportedServices[ i ] ) 1109*cdf0e10cSrcweir return sal_True; 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir return sal_False; 1113*cdf0e10cSrcweir } 1114*cdf0e10cSrcweir 1115*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SvxRectCtlChildAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException ) 1116*cdf0e10cSrcweir { 1117*cdf0e10cSrcweir const ::rtl::OUString sServiceName (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.accessibility.AccessibleContext")); 1118*cdf0e10cSrcweir return Sequence< ::rtl::OUString >( &sServiceName, 1 ); 1119*cdf0e10cSrcweir } 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir //===== XTypeProvider ======================================================= 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationId( void ) throw( RuntimeException ) 1124*cdf0e10cSrcweir { 1125*cdf0e10cSrcweir static OImplementationId* pId = 0; 1126*cdf0e10cSrcweir if( !pId ) 1127*cdf0e10cSrcweir { 1128*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 1129*cdf0e10cSrcweir if( !pId) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir static OImplementationId aId; 1132*cdf0e10cSrcweir pId = &aId; 1133*cdf0e10cSrcweir } 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir return pId->getImplementationId(); 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir 1138*cdf0e10cSrcweir //===== internal ============================================================ 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir void SvxRectCtlChildAccessibleContext::CommitChange( const AccessibleEventObject& rEvent ) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir if (mnClientId) 1143*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent ); 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir void SAL_CALL SvxRectCtlChildAccessibleContext::disposing() 1147*cdf0e10cSrcweir { 1148*cdf0e10cSrcweir if( !rBHelper.bDisposed ) 1149*cdf0e10cSrcweir { 1150*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir // Send a disposing to all listeners. 1153*cdf0e10cSrcweir if ( mnClientId ) 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); 1156*cdf0e10cSrcweir mnClientId = 0; 1157*cdf0e10cSrcweir } 1158*cdf0e10cSrcweir 1159*cdf0e10cSrcweir mxParent = Reference< XAccessible >(); 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir delete mpBoundingBox; 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir void SvxRectCtlChildAccessibleContext::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException ) 1166*cdf0e10cSrcweir { 1167*cdf0e10cSrcweir if( IsNotAlive() ) 1168*cdf0e10cSrcweir throw lang::DisposedException(); 1169*cdf0e10cSrcweir } 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException ) 1172*cdf0e10cSrcweir { 1173*cdf0e10cSrcweir ::osl::MutexGuard aGuard( maMutex ); 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox() 1176*cdf0e10cSrcweir Rectangle aRect( GetBoundingBox() ); 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir return Rectangle( mrParentWindow.OutputToScreenPixel( aRect.TopLeft() ), aRect.GetSize() ); 1179*cdf0e10cSrcweir } 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBox( void ) throw( RuntimeException ) 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir // no guard neccessary, because no one changes mpBoundingBox after creating it 1184*cdf0e10cSrcweir ThrowExceptionIfNotAlive(); 1185*cdf0e10cSrcweir 1186*cdf0e10cSrcweir return *mpBoundingBox; 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir void SvxRectCtlChildAccessibleContext::setStateChecked( sal_Bool bChecked ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir if( mbIsChecked != bChecked ) 1192*cdf0e10cSrcweir { 1193*cdf0e10cSrcweir mbIsChecked = bChecked; 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir const Reference< XInterface > xSource( *this ); 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir Any aOld; 1198*cdf0e10cSrcweir Any aNew; 1199*cdf0e10cSrcweir Any& rMod = bChecked? aNew : aOld; 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir rMod <<= AccessibleStateType::CHECKED; 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) ); 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir 1207