LibreOffice Module chart2 (master) 1
AccessibleBase.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#pragma once
20
21#include <ObjectIdentifier.hxx>
22
23#include <com/sun/star/accessibility/XAccessible.hpp>
24#include <com/sun/star/accessibility/XAccessibleContext.hpp>
25#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27#include <com/sun/star/lang/XEventListener.hpp>
28#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
32#include <rtl/ref.hxx>
33#include <tools/color.hxx>
34#include <unotools/weakref.hxx>
35
36#include <map>
37#include <vector>
38#include <memory>
39
40namespace com::sun::star::awt { class XWindow; }
41namespace com::sun::star::chart2 { class XChartDocument; }
42namespace com::sun::star::view { class XSelectionSupplier; }
43
44
45class SdrView;
46
47namespace accessibility
48{
49class IAccessibleViewForwarder;
50}
51
52namespace chart
53{
54
55class AccessibleBase;
56class ChartView;
57class ObjectHierarchy;
58
60
62{
64
66 css::uno::WeakReference< css::view::XSelectionSupplier > m_xSelectionSupplier;
68 css::uno::WeakReference< css::awt::XWindow > m_xWindow;
69
70 std::shared_ptr< ObjectHierarchy > m_spObjectHierarchy;
71
75};
76
77namespace impl
78{
79typedef ::cppu::WeakComponentImplHelper<
80 css::accessibility::XAccessible,
81 css::accessibility::XAccessibleContext,
82 css::accessibility::XAccessibleComponent,
83 css::accessibility::XAccessibleEventBroadcaster,
84 css::lang::XServiceInfo,
85 css::lang::XEventListener
87}
88
92 public cppu::BaseMutex,
94{
95public:
96 enum class EventType
97 {
98 GOT_SELECTION,
99 LOST_SELECTION
100 };
101
103 bool bMayHaveChildren,
104 bool bAlwaysTransparent );
105 virtual ~AccessibleBase() override;
106
107protected:
108 // for all calls to protected methods it is assumed that the mutex is locked
109 // unless calls outside via UNO, e.g. event notification, are done
110
117 bool CheckDisposeState( bool bThrowException = true ) const;
118
132 bool NotifyEvent( EventType eType, const AccessibleUniqueId & rId );
133
138 void AddState( sal_Int64 aState );
139
145 void RemoveState( sal_Int64 aState );
146
154 bool UpdateChildren();
155
159 virtual bool ImplUpdateChildren();
160
169 void AddChild( AccessibleBase* pChild );
170
175 void RemoveChildByOId( const ObjectIdentifier& rOId );
176
184 virtual css::awt::Point GetUpperLeftOnScreen() const;
185
189 void BroadcastAccEvent( sal_Int16 nId,
190 const css::uno::Any & rNew,
191 const css::uno::Any & rOld ) const;
192
199 void KillAllChildren();
200
207 virtual css::uno::Reference< css::accessibility::XAccessible >
208 ImplGetAccessibleChildById( sal_Int64 i ) const;
209
215 virtual sal_Int64 ImplGetAccessibleChildCount() const;
216
217 const AccessibleElementInfo& GetInfo() const { return m_aAccInfo;}
218 void SetInfo( const AccessibleElementInfo & rNewInfo );
219 const AccessibleUniqueId& GetId() const { return m_aAccInfo.m_aOID;}
220
221 // ________ WeakComponentImplHelper (XComponent::dispose) ________
222 virtual void SAL_CALL disposing() override;
223
224 // ________ XAccessible ________
225 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override;
226
227 // ________ XAccessibleContext ________
228 virtual sal_Int64 SAL_CALL getAccessibleChildCount() override;
229 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
230 getAccessibleChild( sal_Int64 i ) override;
231 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
232 getAccessibleParent() override;
233 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
235 virtual sal_Int16 SAL_CALL getAccessibleRole() override;
236 // has to be implemented by derived classes
237// virtual OUString SAL_CALL getAccessibleName()
238// throw (css::uno::RuntimeException);
239 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL
240 getAccessibleRelationSet() override;
241 virtual sal_Int64 SAL_CALL getAccessibleStateSet() override;
242 virtual css::lang::Locale SAL_CALL getLocale() override;
243 // has to be implemented by derived classes
244// virtual OUString SAL_CALL getAccessibleDescription()
245// throw (css::uno::RuntimeException);
246
247 // ________ XAccessibleComponent ________
248 virtual sal_Bool SAL_CALL containsPoint(
249 const css::awt::Point& aPoint ) override;
250 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
251 getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
252 // has to be defined in derived classes
253 virtual css::awt::Rectangle SAL_CALL getBounds() override;
254 virtual css::awt::Point SAL_CALL getLocation() override;
255 virtual css::awt::Point SAL_CALL getLocationOnScreen() override;
256 virtual css::awt::Size SAL_CALL getSize() override;
257 virtual void SAL_CALL grabFocus() override;
258 virtual sal_Int32 SAL_CALL getForeground() override;
259 virtual sal_Int32 SAL_CALL getBackground() override;
260
261 // ________ XServiceInfo ________
262 virtual OUString SAL_CALL getImplementationName() override;
263 virtual sal_Bool SAL_CALL supportsService(
264 const OUString& ServiceName ) override;
265 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
266
267 // ________ XEventListener ________
268 virtual void SAL_CALL disposing(
269 const css::lang::EventObject& Source ) override;
270
271 // ________ XAccessibleEventBroadcaster ________
272 virtual void SAL_CALL addAccessibleEventListener(
273 const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
274 virtual void SAL_CALL removeAccessibleEventListener(
275 const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
276
277private:
279 {
282 };
283 Color getColor( eColorType eColType );
284
285private:
288 typedef std::vector< css::uno::Reference< css::accessibility::XAccessible > > ChildListVectorType;
292 typedef std::map< ObjectIdentifier, css::uno::Reference< css::accessibility::XAccessible > > ChildOIDMap;
293
298
300
302
305 sal_Int64 m_nStateSet;
306
317};
318
319} // namespace chart
320
321/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for all Chart Accessibility objects.
void KillAllChildren()
Removes all children from the internal lists and broadcasts child remove events.
virtual css::uno::Reference< css::accessibility::XAccessible > ImplGetAccessibleChildById(sal_Int64 i) const
Is called from getAccessibleChild().
virtual sal_Int64 ImplGetAccessibleChildCount() const
Is called from getAccessibleChildCount().
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
AccessibleBase(AccessibleElementInfo aAccInfo, bool bMayHaveChildren, bool bAlwaysTransparent)
void SetInfo(const AccessibleElementInfo &rNewInfo)
std::vector< css::uno::Reference< css::accessibility::XAccessible > > ChildListVectorType
type of the vector containing the accessible children
const AccessibleUniqueId & GetId() const
virtual css::awt::Point GetUpperLeftOnScreen() const
Retrieve the pixel coordinates of logical coordinates (0,0) of the current logic coordinate system.
Color getColor(eColorType eColType)
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::awt::Rectangle SAL_CALL getBounds() override
virtual css::awt::Size SAL_CALL getSize() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
virtual css::awt::Point SAL_CALL getLocation() override
void AddState(sal_Int64 aState)
Adds a state to the set.
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
sal_Int64 m_nStateSet
for getAccessibleStateSet()
volatile bool m_bStateSetInitialized
denotes if the state-set is initialized.
ChildListVectorType m_aChildList
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
bool UpdateChildren()
has to be overridden by derived classes that support child elements.
::comphelper::AccessibleEventNotifier::TClientId m_nEventNotifierId
bool NotifyEvent(EventType eType, const AccessibleUniqueId &rId)
Events coming from the core have to be processed in this methods.
virtual void SAL_CALL grabFocus() override
AccessibleElementInfo m_aAccInfo
virtual ~AccessibleBase() override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
void RemoveChildByOId(const ObjectIdentifier &rOId)
removes a child from the internal vector.
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual void SAL_CALL disposing() override
virtual css::lang::Locale SAL_CALL getLocale() override
bool CheckDisposeState(bool bThrowException=true) const
void BroadcastAccEvent(sal_Int16 nId, const css::uno::Any &rNew, const css::uno::Any &rOld) const
This method creates an AccessibleEventObject and sends it to all listeners that are currently listeni...
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
void RemoveState(sal_Int64 aState)
Removes a state from the set if the set contains the state, otherwise nothing is done.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
void AddChild(AccessibleBase *pChild)
adds a child to the end of the internal vector of children.
const AccessibleElementInfo & GetInfo() const
std::map< ObjectIdentifier, css::uno::Reference< css::accessibility::XAccessible > > ChildOIDMap
type of the hash containing a vector index for every AccessibleUniqueId of the object in the child li...
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual bool ImplUpdateChildren()
Is called by UpdateChildren.
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
::cppu::WeakComponentImplHelper< css::accessibility::XAccessible, css::accessibility::XAccessibleContext, css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleEventBroadcaster, css::lang::XServiceInfo, css::lang::XEventListener > AccessibleBase_Base
ObjectIdentifier AccessibleUniqueId
css::uno::WeakReference< css::awt::XWindow > m_xWindow
std::shared_ptr< ObjectHierarchy > m_spObjectHierarchy
css::uno::WeakReference< css::view::XSelectionSupplier > m_xSelectionSupplier
::accessibility::IAccessibleViewForwarder * m_pViewForwarder
unotools::WeakReference< ::chart::ChartModel > m_xChartDocument
unotools::WeakReference< ::chart::ChartView > m_xView
unsigned char sal_Bool