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
75 protected:
76 css::uno::Reference< css::accessibility::XAccessible >
78
79 public:
91 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
92 const css::uno::Reference< css::accessibility::XAccessible >& _rxInnerAccessible,
93 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
94 );
97
98 // returns the context without creating it
99 css::uno::Reference< css::accessibility::XAccessibleContext >
100 getContextNoCreate( ) const;
101
102 protected:
103 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL
104 getAccessibleContext( ) override;
105
106 const css::uno::Reference< css::accessibility::XAccessible >&
107 getParent() const { return m_xParentAccessible; }
108
109 // own overridables
110 virtual rtl::Reference<OAccessibleContextWrapper> createAccessibleContext(
111 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerContext
112 );
113
114 protected:
115 virtual ~OAccessibleWrapper( ) override;
116
117 private:
120 };
121
122
123 //= OAccessibleContextWrapperHelper
124
125
126 typedef ::cppu::ImplHelper1 < css::accessibility::XAccessibleEventListener
128
147 {
148 protected:
150 css::uno::Reference< css::accessibility::XAccessibleContext >
153 css::uno::Reference< css::accessibility::XAccessible >
156 css::uno::Reference< css::accessibility::XAccessible >
158
159 rtl::Reference<OWrappedAccessibleChildrenManager> m_xChildMapper; // for mapping children from our inner context to our callers
160
161 protected:
180 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
181 ::cppu::OBroadcastHelper& _rBHelper,
182 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
183 const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
184 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
185 );
186
188 void aggregateProxy(
189 oslInterlockedCount& _rRefCount,
190 ::cppu::OWeakObject& _rDelegator
191 );
192
193 protected:
194 // XInterface
195 css::uno::Any SAL_CALL queryInterface( const css::uno::Type& _rType ) override;
196
197 // XTypeProvider
199
200 // XAccessibleContext
202 sal_Int32 baseGetAccessibleChildCount( );
205 css::uno::Reference< css::accessibility::XAccessible > baseGetAccessibleChild( sal_Int32 i );
207 css::uno::Reference< css::accessibility::XAccessibleRelationSet > baseGetAccessibleRelationSet( );
208
209 // XAccessibleEventListener
210 virtual void SAL_CALL notifyEvent( const css::accessibility::AccessibleEventObject& aEvent ) override;
211
212 // XEventListener
213 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
214
215 // XComponent/OComponentProxyAggregationHelper
216 virtual void SAL_CALL dispose() override;
217
218 // own overridables
229 virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) = 0;
230
231 protected:
232 virtual ~OAccessibleContextWrapperHelper( ) override;
233
236 };
237
238
239 //= OAccessibleContextWrapper
240
241 typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessibleEventBroadcaster
242 , css::accessibility::XAccessibleContext
244
246 :public cppu::BaseMutex
249 {
250 private:
252
253 public:
272 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
273 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
274 const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
275 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
276 );
277
278 // XInterface
280 // XTypeProvider
282
283 // XAccessibleContext
284 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
285 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
286 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
287 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
288 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
289 virtual OUString SAL_CALL getAccessibleDescription( ) override;
290 virtual OUString SAL_CALL getAccessibleName( ) override;
291 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
292 virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
293 virtual css::lang::Locale SAL_CALL getLocale( ) override;
294
295 // XAccessibleEventBroadcaster
296 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
297 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
298
299 // OAccessibleContextWrapper
300 virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) override;
301
302 // OComponentHelper
303 using OAccessibleContextWrapperHelper::disposing;
304 virtual void SAL_CALL disposing() override;
305
306 protected:
307 virtual ~OAccessibleContextWrapper() override;
308
309 private:
312 };
313
314
315 //= OWrappedAccessibleChildrenManager
316
317
318 typedef ::std::map < css::uno::Reference< css::accessibility::XAccessible >
319 , rtl::Reference< comphelper::OAccessibleWrapper >
321 // TODO: think about if we should hold these objects weak
322
323 typedef ::cppu::WeakImplHelper< css::lang::XEventListener
327 class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OWrappedAccessibleChildrenManager final : public OWrappedAccessibleChildrenManager_Base
328 {
329 css::uno::Reference< css::uno::XComponentContext >
331 css::uno::WeakReference< css::accessibility::XAccessible >
332 m_aOwningAccessible; // the XAccessible which belongs to the XAccessibleContext which we work for
333 AccessibleMap m_aChildrenMap; // for caching children
334 bool m_bTransientChildren; // are we prohibited to cache our children?
335
336 public:
338 OWrappedAccessibleChildrenManager(
339 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
340 );
341
345 void setTransientChildren( bool _bSet );
346
350 void setOwningAccessible( const css::uno::Reference< css::accessibility::XAccessible >& _rxAcc );
351
353 css::uno::Reference< css::accessibility::XAccessible >
354 getAccessibleWrapperFor(
355 const css::uno::Reference< css::accessibility::XAccessible >& _rxKey
356 );
357
359 void removeFromCache( const css::uno::Reference< css::accessibility::XAccessible >& _rxKey );
360
362 void invalidateAll( );
363
368 void dispose();
369
373 void handleChildNotification( const css::accessibility::AccessibleEventObject& _rEvent );
374
378 void translateAccessibleEvent(
379 const css::accessibility::AccessibleEventObject& _rEvent,
380 css::accessibility::AccessibleEventObject& _rTranslatedEvent
381 );
382
383 private:
384 // XEventListener
385 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
386
387 void implTranslateChildEventValue( const css::uno::Any& _rInValue, css::uno::Any& _rOutValue );
388
389 virtual ~OWrappedAccessibleChildrenManager( ) override;
390
391 OWrappedAccessibleChildrenManager( const OWrappedAccessibleChildrenManager& ) = delete;
392 OWrappedAccessibleChildrenManager& operator=( const OWrappedAccessibleChildrenManager& ) = delete;
393 };
394
395
396} // namespace accessibility
397
398
399#endif // INCLUDED_COMPHELPER_ACCESSIBLEWRAPPER_HXX
400
401/* 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