LibreOffice Module comphelper (master) 1
accessiblewrapper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_COMPHELPER_ACCESSIBLEWRAPPER_HXX
21#define INCLUDED_COMPHELPER_ACCESSIBLEWRAPPER_HXX
22
23#include <config_options.h>
24#include <sal/config.h>
25
26#include <map>
27
29#include <com/sun/star/accessibility/XAccessible.hpp>
30#include <com/sun/star/accessibility/XAccessibleContext.hpp>
31#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
32#include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
37#include <comphelper/uno3.hxx>
41#include <rtl/ref.hxx>
42
43namespace com::sun::star::uno { class XComponentContext; }
44
45namespace comphelper
46{
47
48
49 //= OAccessibleWrapper
50
51
52 class OAccessibleContextWrapper;
53 class OWrappedAccessibleChildrenManager;
54
56 public ::cppu::ImplHelper1 < css::accessibility::XAccessible >
57 {
58 protected:
60 };
61
67
68 {
69 private:
70 css::uno::Reference< css::accessibility::XAccessible >
72 css::uno::WeakReference< css::accessibility::XAccessibleContext >
74 css::uno::Reference< css::accessibility::XAccessible >
76
77 public:
89 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
90 const css::uno::Reference< css::accessibility::XAccessible >& _rxInnerAccessible,
91 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
92 );
95
96 // returns the context without creating it
97 css::uno::Reference< css::accessibility::XAccessibleContext >
98 getContextNoCreate( ) const;
99
100 protected:
101 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL
102 getAccessibleContext( ) override;
103
104 const css::uno::Reference< css::accessibility::XAccessible >&
105 getParent() const { return m_xParentAccessible; }
106
107 // own overridables
108 virtual rtl::Reference<OAccessibleContextWrapper> createAccessibleContext(
109 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerContext
110 );
111
112 protected:
113 virtual ~OAccessibleWrapper( ) override;
114
115 private:
118 };
119
120
121 //= OAccessibleContextWrapperHelper
122
123
124 typedef ::cppu::ImplHelper1 < css::accessibility::XAccessibleEventListener
126
145 {
146 protected:
148 css::uno::Reference< css::accessibility::XAccessibleContext >
151 css::uno::Reference< css::accessibility::XAccessible >
154 css::uno::Reference< css::accessibility::XAccessible >
156
157 rtl::Reference<OWrappedAccessibleChildrenManager> m_xChildMapper; // for mapping children from our inner context to our callers
158
159 protected:
178 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
179 ::cppu::OBroadcastHelper& _rBHelper,
180 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
181 const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
182 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
183 );
184
186 void aggregateProxy(
187 oslInterlockedCount& _rRefCount,
188 ::cppu::OWeakObject& _rDelegator
189 );
190
191 protected:
192 // XInterface
193 css::uno::Any SAL_CALL queryInterface( const css::uno::Type& _rType ) override;
194
195 // XTypeProvider
197
198 // XAccessibleContext
200 sal_Int64 baseGetAccessibleChildCount( );
203 css::uno::Reference< css::accessibility::XAccessible > baseGetAccessibleChild( sal_Int64 i );
205 css::uno::Reference< css::accessibility::XAccessibleRelationSet > baseGetAccessibleRelationSet( );
206
207 // XAccessibleEventListener
208 virtual void SAL_CALL notifyEvent( const css::accessibility::AccessibleEventObject& aEvent ) override;
209
210 // XEventListener
211 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
212
213 // XComponent/OComponentProxyAggregationHelper
214 virtual void SAL_CALL dispose() override;
215
216 // own overridables
227 virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) = 0;
228
229 protected:
230 virtual ~OAccessibleContextWrapperHelper( ) override;
231
234 };
235
236
237 //= OAccessibleContextWrapper
238
239 typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessibleEventBroadcaster
240 , css::accessibility::XAccessibleContext
242
244 :public cppu::BaseMutex
247 {
248 private:
250
251 public:
270 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
271 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
272 const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
273 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
274 );
275
276 // XInterface
278 // XTypeProvider
280
281 // XAccessibleContext
282 virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override;
283 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override;
284 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
285 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override;
286 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
287 virtual OUString SAL_CALL getAccessibleDescription( ) override;
288 virtual OUString SAL_CALL getAccessibleName( ) override;
289 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
290 virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
291 virtual css::lang::Locale SAL_CALL getLocale( ) override;
292
293 // XAccessibleEventBroadcaster
294 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
295 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
296
297 // OAccessibleContextWrapper
298 virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) override;
299
300 // OComponentHelper
301 using OAccessibleContextWrapperHelper::disposing;
302 virtual void SAL_CALL disposing() override;
303
304 protected:
305 virtual ~OAccessibleContextWrapper() override;
306
307 private:
310 };
311
312
313 //= OWrappedAccessibleChildrenManager
314
315
316 typedef ::std::map < css::uno::Reference< css::accessibility::XAccessible >
317 , rtl::Reference< comphelper::OAccessibleWrapper >
319 // TODO: think about if we should hold these objects weak
320
321 typedef ::cppu::WeakImplHelper< css::lang::XEventListener
325 class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OWrappedAccessibleChildrenManager final : public OWrappedAccessibleChildrenManager_Base
326 {
327 css::uno::Reference< css::uno::XComponentContext >
329 css::uno::WeakReference< css::accessibility::XAccessible >
330 m_aOwningAccessible; // the XAccessible which belongs to the XAccessibleContext which we work for
331 AccessibleMap m_aChildrenMap; // for caching children
332 bool m_bTransientChildren; // are we prohibited to cache our children?
333
334 public:
336 OWrappedAccessibleChildrenManager(
337 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
338 );
339
343 void setTransientChildren( bool _bSet );
344
348 void setOwningAccessible( const css::uno::Reference< css::accessibility::XAccessible >& _rxAcc );
349
351 css::uno::Reference< css::accessibility::XAccessible >
352 getAccessibleWrapperFor(
353 const css::uno::Reference< css::accessibility::XAccessible >& _rxKey
354 );
355
357 void removeFromCache( const css::uno::Reference< css::accessibility::XAccessible >& _rxKey );
358
360 void invalidateAll( );
361
366 void dispose();
367
371 void handleChildNotification( const css::accessibility::AccessibleEventObject& _rEvent );
372
376 void translateAccessibleEvent(
377 const css::accessibility::AccessibleEventObject& _rEvent,
378 css::accessibility::AccessibleEventObject& _rTranslatedEvent
379 );
380
381 private:
382 // XEventListener
383 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
384
385 void implTranslateChildEventValue( const css::uno::Any& _rInValue, css::uno::Any& _rOutValue );
386
387 virtual ~OWrappedAccessibleChildrenManager( ) override;
388
389 OWrappedAccessibleChildrenManager( const OWrappedAccessibleChildrenManager& ) = delete;
390 OWrappedAccessibleChildrenManager& operator=( const OWrappedAccessibleChildrenManager& ) = delete;
391 };
392
393
394} // namespace accessibility
395
396
397#endif // INCLUDED_COMPHELPER_ACCESSIBLEWRAPPER_HXX
398
399/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
AnyEventRef aEvent
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
rtl::Reference< OWrappedAccessibleChildrenManager > m_xChildMapper
css::uno::Reference< css::accessibility::XAccessibleContext > m_xInnerContext
the context we're wrapping (properly typed, in opposite to OComponentProxyAggregationHelper::m_xInner...
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
css::uno::Reference< css::accessibility::XAccessible > m_xOwningAccessible
the XAccessible which created this context
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
::comphelper::AccessibleEventNotifier::TClientId m_nNotifierClient
a class which aggregates a proxy for an XAccessible, and wrapping the context returned by this XAcces...
OAccessibleWrapper & operator=(const OAccessibleWrapper &)=delete
css::uno::Reference< css::accessibility::XAccessible > m_xParentAccessible
OAccessibleWrapper(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::accessibility::XAccessible > &_rxInnerAccessible, const css::uno::Reference< css::accessibility::XAccessible > &_rxParentAccessible)
ctor
css::uno::WeakReference< css::accessibility::XAccessibleContext > m_aContext
OAccessibleWrapper(const OAccessibleWrapper &)=delete
css::uno::Reference< css::accessibility::XAccessible > m_xInnerAccessible
a helper class for aggregating a proxy to an XComponent
#define COMPHELPER_DLLPUBLIC
::std::map< css::uno::Reference< css::accessibility::XAccessible >, rtl::Reference< comphelper::OAccessibleWrapper > > AccessibleMap
::cppu::ImplHelper1< css::accessibility::XAccessibleEventListener > OAccessibleContextWrapperHelper_Base
::cppu::WeakComponentImplHelper< css::accessibility::XAccessibleEventBroadcaster, css::accessibility::XAccessibleContext > OAccessibleContextWrapper_CBase
::cppu::WeakImplHelper< css::lang::XEventListener > OWrappedAccessibleChildrenManager_Base
class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OStreamSection
implements handling for compatibly reading/writing data from/into an input/output stream.
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
void dispose()
#define DECLARE_XTYPEPROVIDER()
Definition: uno3.hxx:126
#define DECLARE_XINTERFACE()
Definition: uno3.hxx:90