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