LCOV - code coverage report
Current view: top level - svx/source/accessibility - svxrectctaccessiblecontext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 515 0.0 %
Date: 2014-04-14 Functions: 0 106 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10