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
10cdf0e10cSrcweir *
11*0841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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/AccessibleBrowseBoxBase.hxx"
27cdf0e10cSrcweir #include <svtools/accessibletableprovider.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
47cdf0e10cSrcweir
48cdf0e10cSrcweir // ============================================================================
49cdf0e10cSrcweir
50cdf0e10cSrcweir namespace accessibility {
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace com::sun::star::accessibility::AccessibleStateType;
53cdf0e10cSrcweir // ============================================================================
54cdf0e10cSrcweir
55cdf0e10cSrcweir // Ctor/Dtor/disposing --------------------------------------------------------
56cdf0e10cSrcweir
DBG_NAME(AccessibleBrowseBoxBase)57cdf0e10cSrcweir DBG_NAME( AccessibleBrowseBoxBase )
58cdf0e10cSrcweir
59cdf0e10cSrcweir AccessibleBrowseBoxBase::AccessibleBrowseBoxBase(
60cdf0e10cSrcweir const Reference< XAccessible >& rxParent,
61cdf0e10cSrcweir IAccessibleTableProvider& rBrowseBox,
62cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
63cdf0e10cSrcweir AccessibleBrowseBoxObjType eObjType ) :
64cdf0e10cSrcweir AccessibleBrowseBoxImplHelper( m_aMutex ),
65cdf0e10cSrcweir mxParent( rxParent ),
66cdf0e10cSrcweir mpBrowseBox( &rBrowseBox ),
67cdf0e10cSrcweir m_xFocusWindow(_xFocusWindow),
68cdf0e10cSrcweir maName( rBrowseBox.GetAccessibleObjectName( eObjType ) ),
69cdf0e10cSrcweir maDescription( rBrowseBox.GetAccessibleObjectDescription( eObjType ) ),
70cdf0e10cSrcweir meObjType( eObjType ),
71cdf0e10cSrcweir m_aClientId(0)
72cdf0e10cSrcweir {
73cdf0e10cSrcweir DBG_CTOR( AccessibleBrowseBoxBase, NULL );
74cdf0e10cSrcweir if ( m_xFocusWindow.is() )
75cdf0e10cSrcweir m_xFocusWindow->addFocusListener( this );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
AccessibleBrowseBoxBase(const Reference<XAccessible> & rxParent,IAccessibleTableProvider & rBrowseBox,const::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> & _xFocusWindow,AccessibleBrowseBoxObjType eObjType,const::rtl::OUString & rName,const::rtl::OUString & rDescription)78cdf0e10cSrcweir AccessibleBrowseBoxBase::AccessibleBrowseBoxBase(
79cdf0e10cSrcweir const Reference< XAccessible >& rxParent,
80cdf0e10cSrcweir IAccessibleTableProvider& rBrowseBox,
81cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
82cdf0e10cSrcweir AccessibleBrowseBoxObjType eObjType,
83cdf0e10cSrcweir const ::rtl::OUString& rName,
84cdf0e10cSrcweir const ::rtl::OUString& rDescription ) :
85cdf0e10cSrcweir AccessibleBrowseBoxImplHelper( m_aMutex ),
86cdf0e10cSrcweir mxParent( rxParent ),
87cdf0e10cSrcweir mpBrowseBox( &rBrowseBox ),
88cdf0e10cSrcweir m_xFocusWindow(_xFocusWindow),
89cdf0e10cSrcweir maName( rName ),
90cdf0e10cSrcweir maDescription( rDescription ),
91cdf0e10cSrcweir meObjType( eObjType ),
92cdf0e10cSrcweir m_aClientId(0)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir DBG_CTOR( AccessibleBrowseBoxBase, NULL );
95cdf0e10cSrcweir if ( m_xFocusWindow.is() )
96cdf0e10cSrcweir m_xFocusWindow->addFocusListener( this );
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
~AccessibleBrowseBoxBase()99cdf0e10cSrcweir AccessibleBrowseBoxBase::~AccessibleBrowseBoxBase()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir DBG_DTOR( AccessibleBrowseBoxBase, NULL );
102cdf0e10cSrcweir
103cdf0e10cSrcweir if( isAlive() )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir // increment ref count to prevent double call of Dtor
106cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount );
107cdf0e10cSrcweir dispose();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
disposing()111cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::disposing()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
114cdf0e10cSrcweir if ( m_xFocusWindow.is() )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir BBSolarGuard aSolarGuard;
117cdf0e10cSrcweir m_xFocusWindow->removeFocusListener( this );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir if ( getClientId( ) )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir AccessibleEventNotifier::TClientId nId( getClientId( ) );
123cdf0e10cSrcweir setClientId( 0 );
124cdf0e10cSrcweir AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir mxParent = NULL;
128cdf0e10cSrcweir mpBrowseBox = NULL;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir // XAccessibleContext ---------------------------------------------------------
132cdf0e10cSrcweir
getAccessibleParent()133cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleBrowseBoxBase::getAccessibleParent()
134cdf0e10cSrcweir throw ( uno::RuntimeException )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
137cdf0e10cSrcweir ensureIsAlive();
138cdf0e10cSrcweir return mxParent;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
getAccessibleIndexInParent()141cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxBase::getAccessibleIndexInParent()
142cdf0e10cSrcweir throw ( uno::RuntimeException )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
145cdf0e10cSrcweir ensureIsAlive();
146cdf0e10cSrcweir
147cdf0e10cSrcweir // -1 for child not found/no parent (according to specification)
148cdf0e10cSrcweir sal_Int32 nRet = -1;
149cdf0e10cSrcweir
150cdf0e10cSrcweir Reference< uno::XInterface > xMeMyselfAndI( static_cast< XAccessibleContext* >( this ), uno::UNO_QUERY );
151cdf0e10cSrcweir
152cdf0e10cSrcweir // iterate over parent's children and search for this object
153cdf0e10cSrcweir if( mxParent.is() )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir Reference< XAccessibleContext >
156cdf0e10cSrcweir xParentContext( mxParent->getAccessibleContext() );
157cdf0e10cSrcweir if( xParentContext.is() )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir Reference< uno::XInterface > xChild;
160cdf0e10cSrcweir
161cdf0e10cSrcweir sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
162cdf0e10cSrcweir for( sal_Int32 nChild = 0; nChild < nChildCount; ++nChild )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir xChild = xChild.query( xParentContext->getAccessibleChild( nChild ) );
165cdf0e10cSrcweir
166cdf0e10cSrcweir if ( xMeMyselfAndI.get() == xChild.get() )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir nRet = nChild;
169cdf0e10cSrcweir break;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir return nRet;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
getAccessibleDescription()177cdf0e10cSrcweir OUString SAL_CALL AccessibleBrowseBoxBase::getAccessibleDescription()
178cdf0e10cSrcweir throw ( uno::RuntimeException )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
181cdf0e10cSrcweir ensureIsAlive();
182cdf0e10cSrcweir return maDescription;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
getAccessibleName()185cdf0e10cSrcweir OUString SAL_CALL AccessibleBrowseBoxBase::getAccessibleName()
186cdf0e10cSrcweir throw ( uno::RuntimeException )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
189cdf0e10cSrcweir ensureIsAlive();
190cdf0e10cSrcweir return maName;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL
getAccessibleRelationSet()194cdf0e10cSrcweir AccessibleBrowseBoxBase::getAccessibleRelationSet()
195cdf0e10cSrcweir throw ( uno::RuntimeException )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir ensureIsAlive();
198cdf0e10cSrcweir // BrowseBox does not have relations.
199cdf0e10cSrcweir return new utl::AccessibleRelationSetHelper;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL
getAccessibleStateSet()203cdf0e10cSrcweir AccessibleBrowseBoxBase::getAccessibleStateSet()
204cdf0e10cSrcweir throw ( uno::RuntimeException )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir BBSolarGuard aSolarGuard;
207cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
208cdf0e10cSrcweir // don't check whether alive -> StateSet may contain DEFUNC
209cdf0e10cSrcweir return implCreateStateSetHelper();
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
getLocale()212cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleBrowseBoxBase::getLocale()
213cdf0e10cSrcweir throw ( IllegalAccessibleComponentStateException, uno::RuntimeException )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
216cdf0e10cSrcweir ensureIsAlive();
217cdf0e10cSrcweir if( mxParent.is() )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir Reference< XAccessibleContext >
220cdf0e10cSrcweir xParentContext( mxParent->getAccessibleContext() );
221cdf0e10cSrcweir if( xParentContext.is() )
222cdf0e10cSrcweir return xParentContext->getLocale();
223cdf0e10cSrcweir }
224cdf0e10cSrcweir throw IllegalAccessibleComponentStateException();
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir // XAccessibleComponent -------------------------------------------------------
228cdf0e10cSrcweir
containsPoint(const awt::Point & rPoint)229cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::containsPoint( const awt::Point& rPoint )
230cdf0e10cSrcweir throw ( uno::RuntimeException )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir return Rectangle( Point(), getBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
getBounds()235cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleBrowseBoxBase::getBounds()
236cdf0e10cSrcweir throw ( uno::RuntimeException )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir return AWTRectangle( getBoundingBox() );
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
getLocation()241cdf0e10cSrcweir awt::Point SAL_CALL AccessibleBrowseBoxBase::getLocation()
242cdf0e10cSrcweir throw ( uno::RuntimeException )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir return AWTPoint( getBoundingBox().TopLeft() );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
getLocationOnScreen()247cdf0e10cSrcweir awt::Point SAL_CALL AccessibleBrowseBoxBase::getLocationOnScreen()
248cdf0e10cSrcweir throw ( uno::RuntimeException )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir return AWTPoint( getBoundingBoxOnScreen().TopLeft() );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
getSize()253cdf0e10cSrcweir awt::Size SAL_CALL AccessibleBrowseBoxBase::getSize()
254cdf0e10cSrcweir throw ( uno::RuntimeException )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir return AWTSize( getBoundingBox().GetSize() );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
isShowing()259cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::isShowing()
260cdf0e10cSrcweir throw ( uno::RuntimeException )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir BBSolarGuard aSolarGuard;
263cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
264cdf0e10cSrcweir ensureIsAlive();
265cdf0e10cSrcweir return implIsShowing();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
isVisible()268cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::isVisible()
269cdf0e10cSrcweir throw ( uno::RuntimeException )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet();
272cdf0e10cSrcweir return xStateSet.is() ?
273cdf0e10cSrcweir xStateSet->contains( AccessibleStateType::VISIBLE ) : sal_False;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
isFocusTraversable()276cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::isFocusTraversable()
277cdf0e10cSrcweir throw ( uno::RuntimeException )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = getAccessibleStateSet();
280cdf0e10cSrcweir return xStateSet.is() ?
281cdf0e10cSrcweir xStateSet->contains( AccessibleStateType::FOCUSABLE ) : sal_False;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
focusGained(const::com::sun::star::awt::FocusEvent &)284cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::focusGained( const ::com::sun::star::awt::FocusEvent& ) throw (::com::sun::star::uno::RuntimeException)
285cdf0e10cSrcweir {
286cdf0e10cSrcweir com::sun::star::uno::Any aFocused;
287cdf0e10cSrcweir com::sun::star::uno::Any aEmpty;
288cdf0e10cSrcweir aFocused <<= FOCUSED;
289cdf0e10cSrcweir
290cdf0e10cSrcweir commitEvent(AccessibleEventId::STATE_CHANGED,aFocused,aEmpty);
291cdf0e10cSrcweir }
292cdf0e10cSrcweir // -----------------------------------------------------------------------------
293cdf0e10cSrcweir
focusLost(const::com::sun::star::awt::FocusEvent &)294cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::focusLost( const ::com::sun::star::awt::FocusEvent& ) throw (::com::sun::star::uno::RuntimeException)
295cdf0e10cSrcweir {
296cdf0e10cSrcweir com::sun::star::uno::Any aFocused;
297cdf0e10cSrcweir com::sun::star::uno::Any aEmpty;
298cdf0e10cSrcweir aFocused <<= FOCUSED;
299cdf0e10cSrcweir
300cdf0e10cSrcweir commitEvent(AccessibleEventId::STATE_CHANGED,aEmpty,aFocused);
301cdf0e10cSrcweir }
302cdf0e10cSrcweir // XAccessibleEventBroadcaster ------------------------------------------------
303cdf0e10cSrcweir
addEventListener(const Reference<XAccessibleEventListener> & _rxListener)304cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::addEventListener(
305cdf0e10cSrcweir const Reference< XAccessibleEventListener>& _rxListener )
306cdf0e10cSrcweir throw ( uno::RuntimeException )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir if ( _rxListener.is() )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
311cdf0e10cSrcweir if ( !getClientId( ) )
312cdf0e10cSrcweir setClientId( AccessibleEventNotifier::registerClient( ) );
313cdf0e10cSrcweir
314cdf0e10cSrcweir AccessibleEventNotifier::addEventListener( getClientId( ), _rxListener );
315cdf0e10cSrcweir }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
removeEventListener(const Reference<XAccessibleEventListener> & _rxListener)318cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::removeEventListener(
319cdf0e10cSrcweir const Reference< XAccessibleEventListener>& _rxListener )
320cdf0e10cSrcweir throw ( uno::RuntimeException )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir if( _rxListener.is() && getClientId( ) )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
325cdf0e10cSrcweir sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener );
326cdf0e10cSrcweir if ( !nListenerCount )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir // no listeners anymore
329cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
330cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls
331cdf0e10cSrcweir // NotifyAccessibleEvent, again
332cdf0e10cSrcweir
333cdf0e10cSrcweir AccessibleEventNotifier::TClientId nId( getClientId( ) );
334cdf0e10cSrcweir setClientId( 0 );
335cdf0e10cSrcweir AccessibleEventNotifier::revokeClient( nId );
336cdf0e10cSrcweir }
337cdf0e10cSrcweir }
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir // XTypeProvider --------------------------------------------------------------
341cdf0e10cSrcweir
getImplementationId()342cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxBase::getImplementationId()
343cdf0e10cSrcweir throw ( uno::RuntimeException )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslGlobalMutex() );
346cdf0e10cSrcweir static Sequence< sal_Int8 > aId;
347cdf0e10cSrcweir implCreateUuid( aId );
348cdf0e10cSrcweir return aId;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir
351cdf0e10cSrcweir // XServiceInfo ---------------------------------------------------------------
352cdf0e10cSrcweir
supportsService(const OUString & rServiceName)353cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBrowseBoxBase::supportsService(
354cdf0e10cSrcweir const OUString& rServiceName )
355cdf0e10cSrcweir throw ( uno::RuntimeException )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
358cdf0e10cSrcweir
359cdf0e10cSrcweir Sequence< OUString > aSupportedServices( getSupportedServiceNames() );
360cdf0e10cSrcweir const OUString* pArrBegin = aSupportedServices.getConstArray();
361cdf0e10cSrcweir const OUString* pArrEnd = pArrBegin + aSupportedServices.getLength();
362cdf0e10cSrcweir const OUString* pString = pArrBegin;
363cdf0e10cSrcweir
364cdf0e10cSrcweir for( ; ( pString != pArrEnd ) && ( rServiceName != *pString ); ++pString )
365cdf0e10cSrcweir ;
366cdf0e10cSrcweir
367cdf0e10cSrcweir return pString != pArrEnd;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
getSupportedServiceNames()370cdf0e10cSrcweir Sequence< OUString > SAL_CALL AccessibleBrowseBoxBase::getSupportedServiceNames()
371cdf0e10cSrcweir throw ( uno::RuntimeException )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
374cdf0e10cSrcweir return Sequence< OUString >( &aServiceName, 1 );
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
377cdf0e10cSrcweir // other public methods -------------------------------------------------------
378cdf0e10cSrcweir
setAccessibleName(const OUString & rName)379cdf0e10cSrcweir void AccessibleBrowseBoxBase::setAccessibleName( const OUString& rName )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() );
382cdf0e10cSrcweir Any aOld;
383cdf0e10cSrcweir aOld <<= maName;
384cdf0e10cSrcweir maName = rName;
385cdf0e10cSrcweir
386cdf0e10cSrcweir aGuard.clear();
387cdf0e10cSrcweir
388cdf0e10cSrcweir commitEvent(
389cdf0e10cSrcweir AccessibleEventId::NAME_CHANGED,
390cdf0e10cSrcweir uno::makeAny( maName ),
391cdf0e10cSrcweir aOld );
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
setAccessibleDescription(const OUString & rDescription)394cdf0e10cSrcweir void AccessibleBrowseBoxBase::setAccessibleDescription( const OUString& rDescription )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() );
397cdf0e10cSrcweir Any aOld;
398cdf0e10cSrcweir aOld <<= maDescription;
399cdf0e10cSrcweir maDescription = rDescription;
400cdf0e10cSrcweir
401cdf0e10cSrcweir aGuard.clear();
402cdf0e10cSrcweir
403cdf0e10cSrcweir commitEvent(
404cdf0e10cSrcweir AccessibleEventId::DESCRIPTION_CHANGED,
405cdf0e10cSrcweir uno::makeAny( maDescription ),
406cdf0e10cSrcweir aOld );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir // internal virtual methods ---------------------------------------------------
410cdf0e10cSrcweir
implIsShowing()411cdf0e10cSrcweir sal_Bool AccessibleBrowseBoxBase::implIsShowing()
412cdf0e10cSrcweir {
413cdf0e10cSrcweir sal_Bool bShowing = sal_False;
414cdf0e10cSrcweir if( mxParent.is() )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir Reference< XAccessibleComponent >
417cdf0e10cSrcweir xParentComp( mxParent->getAccessibleContext(), uno::UNO_QUERY );
418cdf0e10cSrcweir if( xParentComp.is() )
419cdf0e10cSrcweir bShowing = implGetBoundingBox().IsOver(
420cdf0e10cSrcweir VCLRectangle( xParentComp->getBounds() ) );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir return bShowing;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir
implCreateStateSetHelper()425cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxBase::implCreateStateSetHelper()
426cdf0e10cSrcweir {
427cdf0e10cSrcweir ::utl::AccessibleStateSetHelper*
428cdf0e10cSrcweir pStateSetHelper = new ::utl::AccessibleStateSetHelper;
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( isAlive() )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir // SHOWING done with mxParent
433cdf0e10cSrcweir if( implIsShowing() )
434cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING );
435cdf0e10cSrcweir // BrowseBox fills StateSet with states depending on object type
436cdf0e10cSrcweir mpBrowseBox->FillAccessibleStateSet( *pStateSetHelper, getType() );
437cdf0e10cSrcweir }
438cdf0e10cSrcweir else
439cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
440cdf0e10cSrcweir
441cdf0e10cSrcweir return pStateSetHelper;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir // internal helper methods ----------------------------------------------------
445cdf0e10cSrcweir
isAlive() const446cdf0e10cSrcweir sal_Bool AccessibleBrowseBoxBase::isAlive() const
447cdf0e10cSrcweir {
448cdf0e10cSrcweir return !rBHelper.bDisposed && !rBHelper.bInDispose && mpBrowseBox;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
ensureIsAlive() const451cdf0e10cSrcweir void AccessibleBrowseBoxBase::ensureIsAlive() const
452cdf0e10cSrcweir throw ( lang::DisposedException )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir if( !isAlive() )
455cdf0e10cSrcweir throw lang::DisposedException();
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
getBoundingBox()458cdf0e10cSrcweir Rectangle AccessibleBrowseBoxBase::getBoundingBox()
459cdf0e10cSrcweir throw ( lang::DisposedException )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir BBSolarGuard aSolarGuard;
462cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
463cdf0e10cSrcweir ensureIsAlive();
464cdf0e10cSrcweir Rectangle aRect = implGetBoundingBox();
465cdf0e10cSrcweir if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir DBG_ERRORFILE( "shit" );
468cdf0e10cSrcweir }
469cdf0e10cSrcweir return aRect;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir
getBoundingBoxOnScreen()472cdf0e10cSrcweir Rectangle AccessibleBrowseBoxBase::getBoundingBoxOnScreen()
473cdf0e10cSrcweir throw ( lang::DisposedException )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir BBSolarGuard aSolarGuard;
476cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
477cdf0e10cSrcweir ensureIsAlive();
478cdf0e10cSrcweir Rectangle aRect = implGetBoundingBoxOnScreen();
479cdf0e10cSrcweir if ( 0 == aRect.Left() && 0 == aRect.Top() && 0 == aRect.Right() && 0 == aRect.Bottom() )
480cdf0e10cSrcweir {
481cdf0e10cSrcweir DBG_ERRORFILE( "shit" );
482cdf0e10cSrcweir }
483cdf0e10cSrcweir return aRect;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
commitEvent(sal_Int16 _nEventId,const Any & _rNewValue,const Any & _rOldValue)486cdf0e10cSrcweir void AccessibleBrowseBoxBase::commitEvent(
487cdf0e10cSrcweir sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( getOslMutex() );
490cdf0e10cSrcweir if ( !getClientId( ) )
491cdf0e10cSrcweir // if we don't have a client id for the notifier, then we don't have listeners, then
492cdf0e10cSrcweir // we don't need to notify anything
493cdf0e10cSrcweir return;
494cdf0e10cSrcweir
495cdf0e10cSrcweir // build an event object
496cdf0e10cSrcweir AccessibleEventObject aEvent;
497cdf0e10cSrcweir aEvent.Source = *this;
498cdf0e10cSrcweir aEvent.EventId = _nEventId;
499cdf0e10cSrcweir aEvent.OldValue = _rOldValue;
500cdf0e10cSrcweir aEvent.NewValue = _rNewValue;
501cdf0e10cSrcweir
502cdf0e10cSrcweir // let the notifier handle this event
503cdf0e10cSrcweir
504cdf0e10cSrcweir AccessibleEventNotifier::addEvent( getClientId( ), aEvent );
505cdf0e10cSrcweir }
506cdf0e10cSrcweir // -----------------------------------------------------------------------------
507cdf0e10cSrcweir
implCreateUuid(Sequence<sal_Int8> & rId)508cdf0e10cSrcweir void AccessibleBrowseBoxBase::implCreateUuid( Sequence< sal_Int8 >& rId )
509cdf0e10cSrcweir {
510cdf0e10cSrcweir if( !rId.hasElements() )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir rId.realloc( 16 );
513cdf0e10cSrcweir rtl_createUuid( reinterpret_cast< sal_uInt8* >( rId.getArray() ), 0, sal_True );
514cdf0e10cSrcweir }
515cdf0e10cSrcweir }
516cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleRole()517cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleBrowseBoxBase::getAccessibleRole()
518cdf0e10cSrcweir throw ( uno::RuntimeException )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir ensureIsAlive();
521cdf0e10cSrcweir sal_Int16 nRole = AccessibleRole::UNKNOWN;
522cdf0e10cSrcweir switch ( meObjType )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir case BBTYPE_ROWHEADERCELL:
525cdf0e10cSrcweir nRole = AccessibleRole::ROW_HEADER;
526cdf0e10cSrcweir break;
527cdf0e10cSrcweir case BBTYPE_COLUMNHEADERCELL:
528cdf0e10cSrcweir nRole = AccessibleRole::COLUMN_HEADER;
529cdf0e10cSrcweir break;
530cdf0e10cSrcweir case BBTYPE_COLUMNHEADERBAR:
531cdf0e10cSrcweir case BBTYPE_ROWHEADERBAR:
532cdf0e10cSrcweir case BBTYPE_TABLE:
533cdf0e10cSrcweir nRole = AccessibleRole::TABLE;
534cdf0e10cSrcweir break;
535cdf0e10cSrcweir case BBTYPE_TABLECELL:
536cdf0e10cSrcweir nRole = AccessibleRole::TABLE_CELL;
537cdf0e10cSrcweir break;
538cdf0e10cSrcweir case BBTYPE_BROWSEBOX:
539cdf0e10cSrcweir nRole = AccessibleRole::PANEL;
540cdf0e10cSrcweir break;
541cdf0e10cSrcweir case BBTYPE_CHECKBOXCELL:
542cdf0e10cSrcweir nRole = AccessibleRole::CHECK_BOX;
543cdf0e10cSrcweir break;
544cdf0e10cSrcweir }
545cdf0e10cSrcweir return nRole;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleKeyBinding()548cdf0e10cSrcweir Any SAL_CALL AccessibleBrowseBoxBase::getAccessibleKeyBinding()
549cdf0e10cSrcweir throw ( uno::RuntimeException )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir return Any();
552cdf0e10cSrcweir }
553cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleAtPoint(const::com::sun::star::awt::Point &)554cdf0e10cSrcweir Reference<XAccessible > SAL_CALL AccessibleBrowseBoxBase::getAccessibleAtPoint( const ::com::sun::star::awt::Point& )
555cdf0e10cSrcweir throw ( uno::RuntimeException )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir return NULL;
558cdf0e10cSrcweir }
559cdf0e10cSrcweir // -----------------------------------------------------------------------------
disposing(const::com::sun::star::lang::EventObject &)560cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxBase::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
561cdf0e10cSrcweir {
562cdf0e10cSrcweir m_xFocusWindow = NULL;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir // -----------------------------------------------------------------------------
getForeground()565cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxBase::getForeground( ) throw (::com::sun::star::uno::RuntimeException)
566cdf0e10cSrcweir {
567cdf0e10cSrcweir BBSolarGuard aSolarGuard;
568cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
569cdf0e10cSrcweir ensureIsAlive();
570cdf0e10cSrcweir
571cdf0e10cSrcweir sal_Int32 nColor = 0;
572cdf0e10cSrcweir Window* pInst = mpBrowseBox->GetWindowInstance();
573cdf0e10cSrcweir if ( pInst )
574cdf0e10cSrcweir {
575cdf0e10cSrcweir if ( pInst->IsControlForeground() )
576cdf0e10cSrcweir nColor = pInst->GetControlForeground().GetColor();
577cdf0e10cSrcweir else
578cdf0e10cSrcweir {
579cdf0e10cSrcweir Font aFont;
580cdf0e10cSrcweir if ( pInst->IsControlFont() )
581cdf0e10cSrcweir aFont = pInst->GetControlFont();
582cdf0e10cSrcweir else
583cdf0e10cSrcweir aFont = pInst->GetFont();
584cdf0e10cSrcweir nColor = aFont.GetColor().GetColor();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
588cdf0e10cSrcweir return nColor;
589cdf0e10cSrcweir }
590cdf0e10cSrcweir // -----------------------------------------------------------------------------
getBackground()591cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxBase::getBackground( ) throw (::com::sun::star::uno::RuntimeException)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir BBSolarGuard aSolarGuard;
594cdf0e10cSrcweir ::osl::MutexGuard aGuard( getOslMutex() );
595cdf0e10cSrcweir ensureIsAlive();
596cdf0e10cSrcweir sal_Int32 nColor = 0;
597cdf0e10cSrcweir Window* pInst = mpBrowseBox->GetWindowInstance();
598cdf0e10cSrcweir if ( pInst )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir if ( pInst->IsControlBackground() )
601cdf0e10cSrcweir nColor = pInst->GetControlBackground().GetColor();
602cdf0e10cSrcweir else
603cdf0e10cSrcweir nColor = pInst->GetBackground().GetColor().GetColor();
604cdf0e10cSrcweir }
605cdf0e10cSrcweir
606cdf0e10cSrcweir return nColor;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir // ============================================================================
610cdf0e10cSrcweir DBG_NAME( BrowseBoxAccessibleElement )
611cdf0e10cSrcweir
612cdf0e10cSrcweir // XInterface -----------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(BrowseBoxAccessibleElement,AccessibleBrowseBoxBase,BrowseBoxAccessibleElement_Base)613cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( BrowseBoxAccessibleElement, AccessibleBrowseBoxBase, BrowseBoxAccessibleElement_Base )
614cdf0e10cSrcweir
615cdf0e10cSrcweir // XTypeProvider --------------------------------------------------------------
616cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( BrowseBoxAccessibleElement, AccessibleBrowseBoxBase, BrowseBoxAccessibleElement_Base )
617cdf0e10cSrcweir
618cdf0e10cSrcweir // XAccessible ----------------------------------------------------------------
619cdf0e10cSrcweir
620cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL BrowseBoxAccessibleElement::getAccessibleContext() throw ( uno::RuntimeException )
621cdf0e10cSrcweir {
622cdf0e10cSrcweir ensureIsAlive();
623cdf0e10cSrcweir return this;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir // ----------------------------------------------------------------------------
BrowseBoxAccessibleElement(const Reference<XAccessible> & rxParent,IAccessibleTableProvider & rBrowseBox,const Reference<awt::XWindow> & _xFocusWindow,AccessibleBrowseBoxObjType eObjType)627cdf0e10cSrcweir BrowseBoxAccessibleElement::BrowseBoxAccessibleElement( const Reference< XAccessible >& rxParent, IAccessibleTableProvider& rBrowseBox,
628cdf0e10cSrcweir const Reference< awt::XWindow >& _xFocusWindow, AccessibleBrowseBoxObjType eObjType )
629cdf0e10cSrcweir :AccessibleBrowseBoxBase( rxParent, rBrowseBox, _xFocusWindow, eObjType )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir DBG_CTOR( BrowseBoxAccessibleElement, NULL );
632cdf0e10cSrcweir }
633cdf0e10cSrcweir
634cdf0e10cSrcweir // ----------------------------------------------------------------------------
BrowseBoxAccessibleElement(const Reference<XAccessible> & rxParent,IAccessibleTableProvider & rBrowseBox,const Reference<awt::XWindow> & _xFocusWindow,AccessibleBrowseBoxObjType eObjType,const::rtl::OUString & rName,const::rtl::OUString & rDescription)635cdf0e10cSrcweir BrowseBoxAccessibleElement::BrowseBoxAccessibleElement( const Reference< XAccessible >& rxParent, IAccessibleTableProvider& rBrowseBox,
636cdf0e10cSrcweir const Reference< awt::XWindow >& _xFocusWindow, AccessibleBrowseBoxObjType eObjType,
637cdf0e10cSrcweir const ::rtl::OUString& rName, const ::rtl::OUString& rDescription )
638cdf0e10cSrcweir :AccessibleBrowseBoxBase( rxParent, rBrowseBox, _xFocusWindow, eObjType, rName, rDescription )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir DBG_CTOR( BrowseBoxAccessibleElement, NULL );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir
643cdf0e10cSrcweir // ----------------------------------------------------------------------------
~BrowseBoxAccessibleElement()644cdf0e10cSrcweir BrowseBoxAccessibleElement::~BrowseBoxAccessibleElement( )
645cdf0e10cSrcweir {
646cdf0e10cSrcweir DBG_DTOR( BrowseBoxAccessibleElement, NULL );
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir // ============================================================================
650cdf0e10cSrcweir
651cdf0e10cSrcweir } // namespace accessibility
652cdf0e10cSrcweir
653cdf0e10cSrcweir // ============================================================================
654cdf0e10cSrcweir
655