21#include <com/sun/star/accessibility/AccessibleEventId.hpp>
22#include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 OWrappedAccessibleChildrenManager::OWrappedAccessibleChildrenManager(
const Reference< XComponentContext >& _rxContext )
34 ,m_bTransientChildren( true )
39 OWrappedAccessibleChildrenManager::~OWrappedAccessibleChildrenManager( )
44 void OWrappedAccessibleChildrenManager::setTransientChildren(
bool _bSet )
46 m_bTransientChildren = _bSet;
50 void OWrappedAccessibleChildrenManager::setOwningAccessible(
const Reference< XAccessible >& _rxAcc )
52 OSL_ENSURE( !m_aOwningAccessible.get().is(),
"OWrappedAccessibleChildrenManager::setOwningAccessible: to be called only once!" );
53 m_aOwningAccessible = WeakReference< XAccessible >( _rxAcc );
57 void OWrappedAccessibleChildrenManager::removeFromCache(
const Reference< XAccessible >& _rxKey )
59 AccessibleMap::iterator aRemovedPos = m_aChildrenMap.find( _rxKey );
60 if ( m_aChildrenMap.end() != aRemovedPos )
63 Reference< XComponent > xComp( aRemovedPos->first, UNO_QUERY );
65 xComp->removeEventListener(
this );
67 m_aChildrenMap.erase( aRemovedPos );
72 void OWrappedAccessibleChildrenManager::invalidateAll( )
75 for(
const auto& rChild : m_aChildrenMap )
77 Reference< XComponent > xComp( rChild.first, UNO_QUERY );
79 xComp->removeEventListener(
this );
86 Reference< XAccessible > OWrappedAccessibleChildrenManager::getAccessibleWrapperFor(
87 const Reference< XAccessible >& _rxKey )
98 AccessibleMap::const_iterator aPos = m_aChildrenMap.find( _rxKey );
99 if ( m_aChildrenMap.end() != aPos )
101 xValue = aPos->second;
106 xValue =
new OAccessibleWrapper( m_xContext, _rxKey, m_aOwningAccessible );
109 if ( !m_bTransientChildren )
111 if (!m_aChildrenMap.emplace( _rxKey, xValue ).second)
114 "OWrappedAccessibleChildrenManager::"
115 "getAccessibleWrapperFor: element was already"
122 Reference< XComponent > xComp( _rxKey, UNO_QUERY );
124 xComp->addEventListener(
this );
132 void OWrappedAccessibleChildrenManager::dispose()
135 for(
const auto& rChild : m_aChildrenMap )
137 Reference< XComponent > xComp( rChild.first, UNO_QUERY );
139 xComp->removeEventListener(
this );
141 Reference< XComponent > xContextComponent;
142 if( rChild.second.is() )
143 xContextComponent.set( rChild.second->getContextNoCreate(),
144 ::css::uno::UNO_QUERY );
145 if( xContextComponent.is() )
146 xContextComponent->dispose();
154 void OWrappedAccessibleChildrenManager::implTranslateChildEventValue(
const Any& _rInValue, Any& _rOutValue )
157 Reference< XAccessible > xChild;
158 if ( _rInValue >>= xChild )
159 _rOutValue <<= getAccessibleWrapperFor( xChild );
163 void OWrappedAccessibleChildrenManager::translateAccessibleEvent(
const AccessibleEventObject& _rEvent, AccessibleEventObject& _rTranslatedEvent )
166 _rTranslatedEvent.NewValue = _rEvent.NewValue;
167 _rTranslatedEvent.OldValue = _rEvent.OldValue;
169 switch ( _rEvent.EventId )
171 case AccessibleEventId::CHILD:
172 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED:
173 case AccessibleEventId::CONTROLLED_BY_RELATION_CHANGED:
174 case AccessibleEventId::CONTROLLER_FOR_RELATION_CHANGED:
175 case AccessibleEventId::LABEL_FOR_RELATION_CHANGED:
176 case AccessibleEventId::LABELED_BY_RELATION_CHANGED:
177 case AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED:
178 case AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED:
180 implTranslateChildEventValue( _rEvent.OldValue, _rTranslatedEvent.OldValue );
181 implTranslateChildEventValue( _rEvent.NewValue, _rTranslatedEvent.NewValue );
184 case AccessibleEventId::NAME_CHANGED:
185 case AccessibleEventId::DESCRIPTION_CHANGED:
186 case AccessibleEventId::ACTION_CHANGED:
187 case AccessibleEventId::STATE_CHANGED:
188 case AccessibleEventId::BOUNDRECT_CHANGED:
189 case AccessibleEventId::INVALIDATE_ALL_CHILDREN:
190 case AccessibleEventId::SELECTION_CHANGED:
191 case AccessibleEventId::VISIBLE_DATA_CHANGED:
192 case AccessibleEventId::VALUE_CHANGED:
193 case AccessibleEventId::MEMBER_OF_RELATION_CHANGED:
194 case AccessibleEventId::CARET_CHANGED:
195 case AccessibleEventId::TEXT_CHANGED:
196 case AccessibleEventId::HYPERTEXT_CHANGED:
197 case AccessibleEventId::TABLE_CAPTION_CHANGED:
198 case AccessibleEventId::TABLE_COLUMN_DESCRIPTION_CHANGED:
199 case AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED:
200 case AccessibleEventId::TABLE_MODEL_CHANGED:
201 case AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED:
202 case AccessibleEventId::TABLE_ROW_HEADER_CHANGED:
203 case AccessibleEventId::TABLE_SUMMARY_CHANGED:
205 case AccessibleEventId::TEXT_SELECTION_CHANGED:
210 OSL_FAIL(
"OWrappedAccessibleChildrenManager::translateAccessibleEvent: unknown (or unexpected) event id!" );
216 void OWrappedAccessibleChildrenManager::handleChildNotification(
const AccessibleEventObject& _rEvent )
218 if ( AccessibleEventId::INVALIDATE_ALL_CHILDREN == _rEvent.EventId )
222 else if ( AccessibleEventId::CHILD == _rEvent.EventId )
225 Reference< XAccessible > xRemoved;
226 if ( _rEvent.OldValue >>= xRemoved )
227 removeFromCache( xRemoved );
232 void SAL_CALL OWrappedAccessibleChildrenManager::disposing(
const EventObject& _rSource )
235 Reference< XAccessible > xSource( _rSource.Source, UNO_QUERY );
236 AccessibleMap::iterator aDisposedPos = m_aChildrenMap.find( xSource );
237#if OSL_DEBUG_LEVEL > 0
238 if ( m_aChildrenMap.end() == aDisposedPos )
240 OSL_FAIL(
"OWrappedAccessibleChildrenManager::disposing: where did this come from?" );
242 Reference< XAccessible > xOwningAccessible( m_aOwningAccessible );
243 Reference< XAccessibleContext > xContext;
246 if ( xOwningAccessible.is() )
247 xContext = xOwningAccessible->getAccessibleContext();
256 catch(
const Exception& )
262 if ( m_aChildrenMap.end() != aDisposedPos )
264 m_aChildrenMap.erase( aDisposedPos );
268 OAccessibleWrapper::OAccessibleWrapper(
const Reference< XComponentContext >& _rxContext,
269 const Reference< XAccessible >& _rxInnerAccessible,
const Reference< XAccessible >& _rxParentAccessible )
270 :OAccessibleWrapper_Base( )
271 ,OComponentProxyAggregation( _rxContext,
Reference< XComponent >( _rxInnerAccessible, UNO_QUERY ) )
272 ,m_xParentAccessible( _rxParentAccessible )
273 ,m_xInnerAccessible( _rxInnerAccessible )
296 if ( !aReturn.hasValue() )
318 Reference< XAccessibleContext > xContext =
m_aContext;
319 if ( !xContext.is() )
322 Reference< XAccessibleContext > xInnerContext =
m_xInnerAccessible->getAccessibleContext( );
323 if ( xInnerContext.is() )
327 m_aContext = WeakReference< XAccessibleContext >( xContext );
335 const Reference< XComponentContext >& _rxContext,
337 const Reference< XAccessibleContext >& _rxInnerAccessibleContext,
338 const Reference< XAccessible >& _rxOwningAccessible,
339 const Reference< XAccessible >& _rxParentAccessible )
341 ,m_xInnerContext( _rxInnerAccessibleContext )
342 ,m_xOwningAccessible( _rxOwningAccessible )
343 ,m_xParentAccessible( _rxParentAccessible )
348 sal_Int64 aStates = m_xInnerContext->getAccessibleStateSet( );
349 m_xChildMapper->setTransientChildren( aStates & AccessibleStateType::MANAGES_DESCENDANTS );
351 m_xChildMapper->setOwningAccessible( m_xOwningAccessible );
358 OSL_ENSURE( xInnerComponent.is(),
"OComponentProxyAggregation::aggregateProxy: accessible is no XComponent!" );
359 if ( xInnerComponent.is() )
363 osl_atomic_increment( &_rRefCount );
365 Reference< XAccessibleEventBroadcaster > xBroadcaster(
m_xInner, UNO_QUERY );
366 if ( xBroadcaster.is() )
367 xBroadcaster->addAccessibleEventListener(
this );
369 osl_atomic_decrement( &_rRefCount );
375 OSL_ENSURE(
m_rBHelper.
bDisposed,
"OAccessibleContextWrapperHelper::~OAccessibleContextWrapperHelper: you should ensure (in your dtor) that the object is disposed!" );
382 if ( !aReturn.hasValue() )
393 return m_xInnerContext->getAccessibleChildCount();
400 Reference< XAccessible > xInnerChild =
m_xInnerContext->getAccessibleChild(
i );
415#if OSL_DEBUG_LEVEL > 0
416 if ( AccessibleEventId::STATE_CHANGED == _rEvent.EventId )
418 bool bChildTransienceChanged =
false;
419 sal_Int64 nChangeState = 0;
420 if ( _rEvent.OldValue >>= nChangeState )
421 bChildTransienceChanged = bChildTransienceChanged || AccessibleStateType::MANAGES_DESCENDANTS == nChangeState;
422 if ( _rEvent.NewValue >>= nChangeState )
423 bChildTransienceChanged = bChildTransienceChanged || AccessibleStateType::MANAGES_DESCENDANTS == nChangeState;
424 OSL_ENSURE( !bChildTransienceChanged,
"OAccessibleContextWrapperHelper::notifyEvent: MANAGES_DESCENDANTS is not expected to change during runtime!" );
429 AccessibleEventObject aTranslatedEvent( _rEvent );
436 m_xChildMapper->translateAccessibleEvent( _rEvent, aTranslatedEvent );
441 if ( aTranslatedEvent.NewValue ==
m_xInner )
442 aTranslatedEvent.NewValue <<= aTranslatedEvent.Source;
443 if ( aTranslatedEvent.OldValue ==
m_xInner )
444 aTranslatedEvent.OldValue <<= aTranslatedEvent.Source;
456 Reference< XAccessibleEventBroadcaster > xBroadcaster(
m_xInner, UNO_QUERY );
457 OSL_ENSURE( xBroadcaster.is(),
"OAccessibleContextWrapperHelper::disposing(): inner context is no broadcaster!" );
458 if ( xBroadcaster.is() )
459 xBroadcaster->removeAccessibleEventListener(
this );
482 const Reference< XAccessibleContext >& _rxInnerAccessibleContext,
const Reference< XAccessible >& _rxOwningAccessible,
483 const Reference< XAccessible >& _rxParentAccessible )
486 ,m_nNotifierClient( 0 )
566 ::osl::MutexGuard aGuard(
m_aMutex );
575 ::osl::MutexGuard aGuard(
m_aMutex );
594 ::osl::MutexGuard aGuard(
m_aMutex );
Reference< XComponentContext > m_xContext
static sal_Int32 addEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
registers a listener for the given client
static void addEvent(const TClientId _nClient, const css::accessibility::AccessibleEventObject &_rEvent)
adds an event, which is to be broadcasted, to the queue
static sal_Int32 removeEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
revokes a listener for the given client
static TClientId registerClient()
registers a client of this class, means a broadcaster of AccessibleEvents
static void revokeClient(const TClientId _nClient)
revokes a broadcaster of AccessibleEvents
static void revokeClientNotifyDisposing(const TClientId _nClient, const css::uno::Reference< css::uno::XInterface > &_rxEventSource)
revokes a client, with additionally notifying a disposing event to all listeners registered for this ...
Helper for wrapping an XAccessibleContext by aggregating a proxy for it.
css::uno::Reference< css::accessibility::XAccessible > m_xParentAccessible
the XAccessible which is to be returned in getAccessibleParent
css::uno::Reference< css::accessibility::XAccessible > baseGetAccessibleChild(sal_Int64 i)
rtl::Reference< OWrappedAccessibleChildrenManager > m_xChildMapper
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void notifyTranslatedEvent(const css::accessibility::AccessibleEventObject &_rEvent)=0
notify an accessible event which has been translated (if necessary)
css::uno::Reference< css::accessibility::XAccessibleContext > m_xInnerContext
the context we're wrapping (properly typed, in opposite to OComponentProxyAggregationHelper::m_xInner...
sal_Int64 baseGetAccessibleChildCount()
OAccessibleContextWrapperHelper(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, ::cppu::OBroadcastHelper &_rBHelper, const css::uno::Reference< css::accessibility::XAccessibleContext > &_rxInnerAccessibleContext, const css::uno::Reference< css::accessibility::XAccessible > &_rxOwningAccessible, const css::uno::Reference< css::accessibility::XAccessible > &_rxParentAccessible)
ctor
virtual ~OAccessibleContextWrapperHelper() override
void aggregateProxy(oslInterlockedCount &_rRefCount, ::cppu::OWeakObject &_rDelegator)
to be called from within your ctor - does the aggregation of a proxy for m_xInnerContext
virtual void SAL_CALL dispose() override
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
css::uno::Reference< css::accessibility::XAccessibleRelationSet > baseGetAccessibleRelationSet()
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual void SAL_CALL disposing() override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::lang::Locale SAL_CALL getLocale() override
virtual ~OAccessibleContextWrapper() override
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual void notifyTranslatedEvent(const css::accessibility::AccessibleEventObject &_rEvent) override
notify an accessible event which has been translated (if necessary)
OAccessibleContextWrapper(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::accessibility::XAccessibleContext > &_rxInnerAccessibleContext, const css::uno::Reference< css::accessibility::XAccessible > &_rxOwningAccessible, const css::uno::Reference< css::accessibility::XAccessible > &_rxParentAccessible)
ctor
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual OUString SAL_CALL getAccessibleName() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
::comphelper::AccessibleEventNotifier::TClientId m_nNotifierClient
virtual OUString SAL_CALL getAccessibleDescription() override
a class which aggregates a proxy for an XAccessible, and wrapping the context returned by this XAcces...
css::uno::Reference< css::accessibility::XAccessibleContext > getContextNoCreate() const
css::uno::Reference< css::accessibility::XAccessible > m_xParentAccessible
virtual ~OAccessibleWrapper() override
css::uno::WeakReference< css::accessibility::XAccessibleContext > m_aContext
virtual rtl::Reference< OAccessibleContextWrapper > createAccessibleContext(const css::uno::Reference< css::accessibility::XAccessibleContext > &_rxInnerContext)
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
css::uno::Reference< css::accessibility::XAccessible > m_xInnerAccessible
a helper class for aggregating a proxy to an XComponent
virtual void SAL_CALL dispose()=0
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
::cppu::OBroadcastHelper & m_rBHelper
void componentAggregateProxyFor(const css::uno::Reference< css::lang::XComponent > &_rxComponent, oslInterlockedCount &_rRefCount, ::cppu::OWeakObject &_rDelegator)
to be called from within your ctor
css::uno::Reference< css::lang::XComponent > m_xInner
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual void SAL_CALL dispose() override
mutable::osl::Mutex m_aMutex
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
::std::map< css::uno::Reference< css::accessibility::XAccessible >, rtl::Reference< comphelper::OAccessibleWrapper > > AccessibleMap
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
::cppu::WeakComponentImplHelper< css::accessibility::XAccessibleEventBroadcaster, css::accessibility::XAccessibleContext > OAccessibleContextWrapper_CBase
#define IMPLEMENT_FORWARD_REFCOUNT(classname, refcountbase)
#define IMPLEMENT_FORWARD_XTYPEPROVIDER2(classname, baseclass1, baseclass2)
#define IMPLEMENT_FORWARD_XINTERFACE2(classname, refcountbase, baseclass2)