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