1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*0841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*0841af79SAndrew Rist * distributed with this work for additional information
6*0841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*0841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist * with the License. You may obtain a copy of the License at
10*0841af79SAndrew Rist *
11*0841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*0841af79SAndrew Rist *
13*0841af79SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist * software distributed under the License is distributed on an
15*0841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist * KIND, either express or implied. See the License for the
17*0841af79SAndrew Rist * specific language governing permissions and limitations
18*0841af79SAndrew Rist * under the License.
19*0841af79SAndrew Rist *
20*0841af79SAndrew Rist *************************************************************/
21*0841af79SAndrew Rist
22*0841af79SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlBase.hxx"
27cdf0e10cSrcweir #include <svtools/accessibletable.hxx>
28cdf0e10cSrcweir #include <rtl/uuid.h>
29cdf0e10cSrcweir //
30cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
31cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir // ============================================================================
35cdf0e10cSrcweir
36cdf0e10cSrcweir using ::rtl::OUString;
37cdf0e10cSrcweir
38cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
39cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
40cdf0e10cSrcweir using ::com::sun::star::uno::Any;
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace ::com::sun::star;
43cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
44cdf0e10cSrcweir using namespace ::comphelper;
45cdf0e10cSrcweir using namespace ::svt;
46cdf0e10cSrcweir using namespace ::svt::table;
47cdf0e10cSrcweir
48cdf0e10cSrcweir
49cdf0e10cSrcweir // ============================================================================
50cdf0e10cSrcweir
51cdf0e10cSrcweir namespace accessibility {
52cdf0e10cSrcweir
53cdf0e10cSrcweir using namespace com::sun::star::accessibility::AccessibleStateType;
54cdf0e10cSrcweir // ============================================================================
55cdf0e10cSrcweir
DBG_NAME(AccessibleGridControlBase)56cdf0e10cSrcweir DBG_NAME( AccessibleGridControlBase )
57cdf0e10cSrcweir
58cdf0e10cSrcweir AccessibleGridControlBase::AccessibleGridControlBase(
59cdf0e10cSrcweir const Reference< XAccessible >& rxParent,
60cdf0e10cSrcweir svt::table::IAccessibleTable& rTable,
61cdf0e10cSrcweir AccessibleTableControlObjType eObjType ) :
62cdf0e10cSrcweir AccessibleGridControlImplHelper( m_aMutex ),
63cdf0e10cSrcweir m_xParent( rxParent ),
64cdf0e10cSrcweir m_aTable( rTable),
65cdf0e10cSrcweir m_eObjType( eObjType ),
66cdf0e10cSrcweir m_aName( rTable.GetAccessibleObjectName( eObjType, 0, 0 ) ),
67cdf0e10cSrcweir m_aDescription( rTable.GetAccessibleObjectDescription( eObjType ) ),
68cdf0e10cSrcweir m_aClientId(0)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
~AccessibleGridControlBase()72cdf0e10cSrcweir AccessibleGridControlBase::~AccessibleGridControlBase()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir if( isAlive() )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir // increment ref count to prevent double call of Dtor
77cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount );
78cdf0e10cSrcweir dispose();
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
disposing()82cdf0e10cSrcweir void SAL_CALL AccessibleGridControlBase::disposing()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
85cdf0e10cSrcweir
86cdf0e10cSrcweir if ( getClientId( ) )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir AccessibleEventNotifier::TClientId nId( getClientId( ) );
89cdf0e10cSrcweir setClientId( 0 );
90cdf0e10cSrcweir AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir m_xParent = NULL;
94cdf0e10cSrcweir //m_aTable = NULL;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir // XAccessibleContext ---------------------------------------------------------
98cdf0e10cSrcweir
getAccessibleParent()99cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleGridControlBase::getAccessibleParent()
100cdf0e10cSrcweir throw ( uno::RuntimeException )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
103cdf0e10cSrcweir ensureIsAlive();
104cdf0e10cSrcweir return m_xParent;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
getAccessibleIndexInParent()107cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControlBase::getAccessibleIndexInParent()
108cdf0e10cSrcweir throw ( uno::RuntimeException )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
111cdf0e10cSrcweir ensureIsAlive();
112cdf0e10cSrcweir
113cdf0e10cSrcweir // -1 for child not found/no parent (according to specification)
114cdf0e10cSrcweir sal_Int32 nRet = -1;
115cdf0e10cSrcweir
116cdf0e10cSrcweir Reference< uno::XInterface > xMeMyselfAndI( static_cast< XAccessibleContext* >( this ), uno::UNO_QUERY );
117cdf0e10cSrcweir
118cdf0e10cSrcweir // iterate over parent's children and search for this object
119cdf0e10cSrcweir if( m_xParent.is() )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir Reference< XAccessibleContext >
122cdf0e10cSrcweir xParentContext( m_xParent->getAccessibleContext() );
123cdf0e10cSrcweir if( xParentContext.is() )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir Reference< uno::XInterface > xChild;
126cdf0e10cSrcweir
127cdf0e10cSrcweir sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
128cdf0e10cSrcweir for( sal_Int32 nChild = 0; nChild < nChildCount; ++nChild )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir xChild = xChild.query( xParentContext->getAccessibleChild( nChild ) );
131cdf0e10cSrcweir if ( xMeMyselfAndI.get() == xChild.get() )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir nRet = nChild;
134cdf0e10cSrcweir break;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir }
137cdf0e10cSrcweir }
138cdf0e10cSrcweir }
139cdf0e10cSrcweir return nRet;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
getAccessibleDescription()142cdf0e10cSrcweir OUString SAL_CALL AccessibleGridControlBase::getAccessibleDescription()
143cdf0e10cSrcweir throw ( uno::RuntimeException )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
146cdf0e10cSrcweir ensureIsAlive();
147cdf0e10cSrcweir return m_aDescription;
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
getAccessibleName()150cdf0e10cSrcweir OUString SAL_CALL AccessibleGridControlBase::getAccessibleName()
151cdf0e10cSrcweir throw ( uno::RuntimeException )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
154cdf0e10cSrcweir ensureIsAlive();
155cdf0e10cSrcweir return m_aName;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL
getAccessibleRelationSet()159cdf0e10cSrcweir AccessibleGridControlBase::getAccessibleRelationSet()
160cdf0e10cSrcweir throw ( uno::RuntimeException )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir ensureIsAlive();
163cdf0e10cSrcweir // GridControl does not have relations.
164cdf0e10cSrcweir return new utl::AccessibleRelationSetHelper;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL
getAccessibleStateSet()168cdf0e10cSrcweir AccessibleGridControlBase::getAccessibleStateSet()
169cdf0e10cSrcweir throw ( uno::RuntimeException )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir TCSolarGuard aSolarGuard;
172cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
173cdf0e10cSrcweir // don't check whether alive -> StateSet may contain DEFUNC
174cdf0e10cSrcweir return implCreateStateSetHelper();
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
getLocale()177cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleGridControlBase::getLocale()
178cdf0e10cSrcweir throw ( IllegalAccessibleComponentStateException, uno::RuntimeException )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
181cdf0e10cSrcweir ensureIsAlive();
182cdf0e10cSrcweir if( m_xParent.is() )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir Reference< XAccessibleContext >
185cdf0e10cSrcweir xParentContext( m_xParent->getAccessibleContext() );
186cdf0e10cSrcweir if( xParentContext.is() )
187cdf0e10cSrcweir return xParentContext->getLocale();
188cdf0e10cSrcweir }
189cdf0e10cSrcweir throw IllegalAccessibleComponentStateException();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir // XAccessibleComponent -------------------------------------------------------
193cdf0e10cSrcweir
containsPoint(const awt::Point & rPoint)194cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlBase::containsPoint( const awt::Point& rPoint )
195cdf0e10cSrcweir throw ( uno::RuntimeException )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir return Rectangle( Point(), getBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
getBounds()200cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleGridControlBase::getBounds()
201cdf0e10cSrcweir throw ( uno::RuntimeException )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir return AWTRectangle( getBoundingBox() );
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
getLocation()206cdf0e10cSrcweir awt::Point SAL_CALL AccessibleGridControlBase::getLocation()
207cdf0e10cSrcweir throw ( uno::RuntimeException )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir return AWTPoint( getBoundingBox().TopLeft() );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
getLocationOnScreen()212cdf0e10cSrcweir awt::Point SAL_CALL AccessibleGridControlBase::getLocationOnScreen()
213cdf0e10cSrcweir throw ( uno::RuntimeException )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir return AWTPoint( getBoundingBoxOnScreen().TopLeft() );
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
getSize()218cdf0e10cSrcweir awt::Size SAL_CALL AccessibleGridControlBase::getSize()
219cdf0e10cSrcweir throw ( uno::RuntimeException )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir return AWTSize( getBoundingBox().GetSize() );
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
isShowing()224cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlBase::isShowing()
225cdf0e10cSrcweir throw ( uno::RuntimeException )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir TCSolarGuard aSolarGuard;
228cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
229cdf0e10cSrcweir ensureIsAlive();
230cdf0e10cSrcweir return implIsShowing();
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
isVisible()233cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlBase::isVisible()
234cdf0e10cSrcweir throw ( uno::RuntimeException )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet();
237cdf0e10cSrcweir return xStateSet.is() ?
238cdf0e10cSrcweir xStateSet->contains( AccessibleStateType::VISIBLE ) : sal_False;
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
isFocusTraversable()241cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlBase::isFocusTraversable()
242cdf0e10cSrcweir throw ( uno::RuntimeException )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet();
245cdf0e10cSrcweir return xStateSet.is() ?
246cdf0e10cSrcweir xStateSet->contains( AccessibleStateType::FOCUSABLE ) : sal_False;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir // XAccessibleEventBroadcaster ------------------------------------------------
249cdf0e10cSrcweir
addEventListener(const Reference<XAccessibleEventListener> & _rxListener)250cdf0e10cSrcweir void SAL_CALL AccessibleGridControlBase::addEventListener(
251cdf0e10cSrcweir const Reference< XAccessibleEventListener>& _rxListener )
252cdf0e10cSrcweir throw ( uno::RuntimeException )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir if ( _rxListener.is() )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
257cdf0e10cSrcweir if ( !getClientId( ) )
258cdf0e10cSrcweir setClientId( AccessibleEventNotifier::registerClient( ) );
259cdf0e10cSrcweir
260cdf0e10cSrcweir AccessibleEventNotifier::addEventListener( getClientId( ), _rxListener );
261cdf0e10cSrcweir }
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
removeEventListener(const Reference<XAccessibleEventListener> & _rxListener)264cdf0e10cSrcweir void SAL_CALL AccessibleGridControlBase::removeEventListener(
265cdf0e10cSrcweir const Reference< XAccessibleEventListener>& _rxListener )
266cdf0e10cSrcweir throw ( uno::RuntimeException )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir if( _rxListener.is() && getClientId( ) )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
271cdf0e10cSrcweir sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener );
272cdf0e10cSrcweir if ( !nListenerCount )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir // no listeners anymore
275cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
276cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls
277cdf0e10cSrcweir // NotifyAccessibleEvent, again
278cdf0e10cSrcweir AccessibleEventNotifier::TClientId nId( getClientId( ) );
279cdf0e10cSrcweir setClientId( 0 );
280cdf0e10cSrcweir AccessibleEventNotifier::revokeClient( nId );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir }
283cdf0e10cSrcweir }
284cdf0e10cSrcweir
285cdf0e10cSrcweir // XTypeProvider --------------------------------------------------------------
286cdf0e10cSrcweir
getImplementationId()287cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL AccessibleGridControlBase::getImplementationId()
288cdf0e10cSrcweir throw ( uno::RuntimeException )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslGlobalMutex() );
291cdf0e10cSrcweir static Sequence< sal_Int8 > aId;
292cdf0e10cSrcweir implCreateUuid( aId );
293cdf0e10cSrcweir return aId;
294cdf0e10cSrcweir }
295cdf0e10cSrcweir
296cdf0e10cSrcweir // XServiceInfo ---------------------------------------------------------------
297cdf0e10cSrcweir
supportsService(const OUString & rServiceName)298cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlBase::supportsService(
299cdf0e10cSrcweir const OUString& rServiceName )
300cdf0e10cSrcweir throw ( uno::RuntimeException )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
303cdf0e10cSrcweir
304cdf0e10cSrcweir Sequence< OUString > aSupportedServices( getSupportedServiceNames() );
305cdf0e10cSrcweir const OUString* pArrBegin = aSupportedServices.getConstArray();
306cdf0e10cSrcweir const OUString* pArrEnd = pArrBegin + aSupportedServices.getLength();
307cdf0e10cSrcweir const OUString* pString = pArrBegin;
308cdf0e10cSrcweir
309cdf0e10cSrcweir for( ; ( pString != pArrEnd ) && ( rServiceName != *pString ); ++pString )
310cdf0e10cSrcweir ;
311cdf0e10cSrcweir return pString != pArrEnd;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
getSupportedServiceNames()314cdf0e10cSrcweir Sequence< OUString > SAL_CALL AccessibleGridControlBase::getSupportedServiceNames()
315cdf0e10cSrcweir throw ( uno::RuntimeException )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
318cdf0e10cSrcweir return Sequence< OUString >( &aServiceName, 1 );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir // internal virtual methods ---------------------------------------------------
321cdf0e10cSrcweir
implIsShowing()322cdf0e10cSrcweir sal_Bool AccessibleGridControlBase::implIsShowing()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir sal_Bool bShowing = sal_False;
325cdf0e10cSrcweir if( m_xParent.is() )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir Reference< XAccessibleComponent >
328cdf0e10cSrcweir xParentComp( m_xParent->getAccessibleContext(), uno::UNO_QUERY );
329cdf0e10cSrcweir if( xParentComp.is() )
330cdf0e10cSrcweir bShowing = implGetBoundingBox().IsOver(
331cdf0e10cSrcweir VCLRectangle( xParentComp->getBounds() ) );
332cdf0e10cSrcweir }
333cdf0e10cSrcweir return bShowing;
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
implCreateStateSetHelper()336cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* AccessibleGridControlBase::implCreateStateSetHelper()
337cdf0e10cSrcweir {
338cdf0e10cSrcweir ::utl::AccessibleStateSetHelper*
339cdf0e10cSrcweir pStateSetHelper = new ::utl::AccessibleStateSetHelper;
340cdf0e10cSrcweir
341cdf0e10cSrcweir if( isAlive() )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir // SHOWING done with m_xParent
344cdf0e10cSrcweir if( implIsShowing() )
345cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING );
346cdf0e10cSrcweir // GridControl fills StateSet with states depending on object type
347cdf0e10cSrcweir m_aTable.FillAccessibleStateSet( *pStateSetHelper, getType() );
348cdf0e10cSrcweir }
349cdf0e10cSrcweir else
350cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
351cdf0e10cSrcweir return pStateSetHelper;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir // internal helper methods ----------------------------------------------------
355cdf0e10cSrcweir
isAlive() const356cdf0e10cSrcweir sal_Bool AccessibleGridControlBase::isAlive() const
357cdf0e10cSrcweir {
358cdf0e10cSrcweir return !rBHelper.bDisposed && !rBHelper.bInDispose && &m_aTable;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
ensureIsAlive() const361cdf0e10cSrcweir void AccessibleGridControlBase::ensureIsAlive() const
362cdf0e10cSrcweir throw ( lang::DisposedException )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir if( !isAlive() )
365cdf0e10cSrcweir throw lang::DisposedException();
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
getBoundingBox()368cdf0e10cSrcweir Rectangle AccessibleGridControlBase::getBoundingBox()
369cdf0e10cSrcweir throw ( lang::DisposedException )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir TCSolarGuard aSolarGuard;
372cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
373cdf0e10cSrcweir ensureIsAlive();
374cdf0e10cSrcweir Rectangle aRect = implGetBoundingBox();
375cdf0e10cSrcweir if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir DBG_ERRORFILE( "rectangle doesn't exist" );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir return aRect;
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
getBoundingBoxOnScreen()382cdf0e10cSrcweir Rectangle AccessibleGridControlBase::getBoundingBoxOnScreen()
383cdf0e10cSrcweir throw ( lang::DisposedException )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir TCSolarGuard aSolarGuard;
386cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
387cdf0e10cSrcweir ensureIsAlive();
388cdf0e10cSrcweir Rectangle aRect = implGetBoundingBoxOnScreen();
389cdf0e10cSrcweir if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir DBG_ERRORFILE( "rectangle doesn't exist" );
392cdf0e10cSrcweir }
393cdf0e10cSrcweir return aRect;
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
commitEvent(sal_Int16 _nEventId,const Any & _rNewValue,const Any & _rOldValue)396cdf0e10cSrcweir void AccessibleGridControlBase::commitEvent(
397cdf0e10cSrcweir sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() );
400cdf0e10cSrcweir if ( !getClientId( ) )
401cdf0e10cSrcweir // if we don't have a client id for the notifier, then we don't have listeners, then
402cdf0e10cSrcweir // we don't need to notify anything
403cdf0e10cSrcweir return;
404cdf0e10cSrcweir
405cdf0e10cSrcweir // build an event object
406cdf0e10cSrcweir AccessibleEventObject aEvent;
407cdf0e10cSrcweir aEvent.Source = *this;
408cdf0e10cSrcweir aEvent.EventId = _nEventId;
409cdf0e10cSrcweir aEvent.OldValue = _rOldValue;
410cdf0e10cSrcweir aEvent.NewValue = _rNewValue;
411cdf0e10cSrcweir
412cdf0e10cSrcweir // let the notifier handle this event
413cdf0e10cSrcweir
414cdf0e10cSrcweir AccessibleEventNotifier::addEvent( getClientId( ), aEvent );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir // -----------------------------------------------------------------------------
417cdf0e10cSrcweir
implCreateUuid(Sequence<sal_Int8> & rId)418cdf0e10cSrcweir void AccessibleGridControlBase::implCreateUuid( Sequence< sal_Int8 >& rId )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir if( !rId.hasElements() )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir rId.realloc( 16 );
423cdf0e10cSrcweir rtl_createUuid( reinterpret_cast< sal_uInt8* >( rId.getArray() ), 0, sal_True );
424cdf0e10cSrcweir }
425cdf0e10cSrcweir }
426cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleRole()427cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleGridControlBase::getAccessibleRole()
428cdf0e10cSrcweir throw ( uno::RuntimeException )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir ensureIsAlive();
431cdf0e10cSrcweir sal_Int16 nRole = AccessibleRole::UNKNOWN;
432cdf0e10cSrcweir switch ( m_eObjType )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir case TCTYPE_ROWHEADERCELL:
435cdf0e10cSrcweir nRole = AccessibleRole::ROW_HEADER;
436cdf0e10cSrcweir break;
437cdf0e10cSrcweir case TCTYPE_COLUMNHEADERCELL:
438cdf0e10cSrcweir nRole = AccessibleRole::COLUMN_HEADER;
439cdf0e10cSrcweir break;
440cdf0e10cSrcweir case TCTYPE_COLUMNHEADERBAR:
441cdf0e10cSrcweir case TCTYPE_ROWHEADERBAR:
442cdf0e10cSrcweir case TCTYPE_TABLE:
443cdf0e10cSrcweir nRole = AccessibleRole::TABLE;
444cdf0e10cSrcweir break;
445cdf0e10cSrcweir case TCTYPE_TABLECELL:
446cdf0e10cSrcweir nRole = AccessibleRole::TABLE_CELL;
447cdf0e10cSrcweir break;
448cdf0e10cSrcweir case TCTYPE_GRIDCONTROL:
449cdf0e10cSrcweir nRole = AccessibleRole::PANEL;
450cdf0e10cSrcweir break;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir return nRole;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleKeyBinding()455cdf0e10cSrcweir Any SAL_CALL AccessibleGridControlBase::getAccessibleKeyBinding()
456cdf0e10cSrcweir throw ( uno::RuntimeException )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir return Any();
459cdf0e10cSrcweir }
460cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleAtPoint(const::com::sun::star::awt::Point &)461cdf0e10cSrcweir Reference<XAccessible > SAL_CALL AccessibleGridControlBase::getAccessibleAtPoint( const ::com::sun::star::awt::Point& )
462cdf0e10cSrcweir throw ( uno::RuntimeException )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir return NULL;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir //// -----------------------------------------------------------------------------
getForeground()467cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControlBase::getForeground( ) throw (::com::sun::star::uno::RuntimeException)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir TCSolarGuard aSolarGuard;
470cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
471cdf0e10cSrcweir ensureIsAlive();
472cdf0e10cSrcweir
473cdf0e10cSrcweir sal_Int32 nColor = 0;
474cdf0e10cSrcweir Window* pInst = m_aTable.GetWindowInstance();
475cdf0e10cSrcweir if ( pInst )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir if ( pInst->IsControlForeground() )
478cdf0e10cSrcweir nColor = pInst->GetControlForeground().GetColor();
479cdf0e10cSrcweir else
480cdf0e10cSrcweir {
481cdf0e10cSrcweir Font aFont;
482cdf0e10cSrcweir if ( pInst->IsControlFont() )
483cdf0e10cSrcweir aFont = pInst->GetControlFont();
484cdf0e10cSrcweir else
485cdf0e10cSrcweir aFont = pInst->GetFont();
486cdf0e10cSrcweir nColor = aFont.GetColor().GetColor();
487cdf0e10cSrcweir }
488cdf0e10cSrcweir }
489cdf0e10cSrcweir return nColor;
490cdf0e10cSrcweir }
491cdf0e10cSrcweir // -----------------------------------------------------------------------------
getBackground()492cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControlBase::getBackground( ) throw (::com::sun::star::uno::RuntimeException)
493cdf0e10cSrcweir {
494cdf0e10cSrcweir TCSolarGuard aSolarGuard;
495cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
496cdf0e10cSrcweir ensureIsAlive();
497cdf0e10cSrcweir sal_Int32 nColor = 0;
498cdf0e10cSrcweir Window* pInst = m_aTable.GetWindowInstance();
499cdf0e10cSrcweir if ( pInst )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir if ( pInst->IsControlBackground() )
502cdf0e10cSrcweir nColor = pInst->GetControlBackground().GetColor();
503cdf0e10cSrcweir else
504cdf0e10cSrcweir nColor = pInst->GetBackground().GetColor().GetColor();
505cdf0e10cSrcweir }
506cdf0e10cSrcweir return nColor;
507cdf0e10cSrcweir }
508cdf0e10cSrcweir
509cdf0e10cSrcweir //// ============================================================================
GridControlAccessibleElement(const Reference<XAccessible> & rxParent,IAccessibleTable & rTable,AccessibleTableControlObjType eObjType)510cdf0e10cSrcweir GridControlAccessibleElement::GridControlAccessibleElement( const Reference< XAccessible >& rxParent,
511cdf0e10cSrcweir IAccessibleTable& rTable,
512cdf0e10cSrcweir AccessibleTableControlObjType eObjType )
513cdf0e10cSrcweir :AccessibleGridControlBase( rxParent, rTable, eObjType )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir }
516cdf0e10cSrcweir
517cdf0e10cSrcweir // XInterface -----------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(GridControlAccessibleElement,AccessibleGridControlBase,GridControlAccessibleElement_Base)518cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( GridControlAccessibleElement, AccessibleGridControlBase, GridControlAccessibleElement_Base)
519cdf0e10cSrcweir
520cdf0e10cSrcweir // XTypeProvider --------------------------------------------------------------
521cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridControlAccessibleElement, AccessibleGridControlBase, GridControlAccessibleElement_Base )
522cdf0e10cSrcweir
523cdf0e10cSrcweir // XAccessible ----------------------------------------------------------------
524cdf0e10cSrcweir
525cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL GridControlAccessibleElement::getAccessibleContext() throw ( uno::RuntimeException )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir ensureIsAlive();
528cdf0e10cSrcweir return this;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir // ----------------------------------------------------------------------------
~GridControlAccessibleElement()531cdf0e10cSrcweir GridControlAccessibleElement::~GridControlAccessibleElement( )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir }
534cdf0e10cSrcweir
535cdf0e10cSrcweir // ============================================================================
536cdf0e10cSrcweir
537cdf0e10cSrcweir } // namespace accessibility
538cdf0e10cSrcweir
539cdf0e10cSrcweir // ============================================================================
540cdf0e10cSrcweir
541