LibreOffice Module sc (master)  1
AccessibleContextBase.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 #pragma once
21 
22 #include <com/sun/star/accessibility/XAccessible.hpp>
23 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
24 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
25 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
29 
30 #include <svl/lstner.hxx>
31 #include <cppuhelper/basemutex.hxx>
32 #include <cppuhelper/compbase5.hxx>
33 #include <cppuhelper/implbase1.hxx>
34 
35 namespace tools { class Rectangle; }
36 
43  css::accessibility::XAccessible,
44  css::accessibility::XAccessibleComponent,
45  css::accessibility::XAccessibleContext,
46  css::accessibility::XAccessibleEventBroadcaster,
47  css::lang::XServiceInfo
49 
50 typedef cppu::ImplHelper1<
51  css::accessibility::XAccessibleEventListener
53 
55  : public cppu::BaseMutex,
58  public SfxListener
59 {
60 public:
61  //===== internal ========================================================
63  const css::uno::Reference<css::accessibility::XAccessible>& rxParent,
64  const sal_Int16 aRole);
65 
66  virtual void Init();
67  virtual void SAL_CALL disposing() override;
68 protected:
69  virtual ~ScAccessibleContextBase() override;
70 public:
71 
73  bool isShowing();
74 
76  virtual bool isVisible();
77 
79 
80  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
81 
83 
84  virtual css::uno::Any SAL_CALL queryInterface(
85  css::uno::Type const & rType ) override;
86 
87  virtual void SAL_CALL acquire() throw () override;
88 
89  virtual void SAL_CALL release() throw () override;
90 
92 
94  virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL
95  getAccessibleContext() override;
96 
98 
99  virtual sal_Bool SAL_CALL containsPoint(
100  const css::awt::Point& rPoint ) override;
101 
102  virtual css::uno::Reference< css::accessibility::XAccessible >
103  SAL_CALL getAccessibleAtPoint(
104  const css::awt::Point& rPoint ) override;
105 
106  virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
107 
108  virtual css::awt::Point SAL_CALL getLocation( ) override;
109 
110  virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
111 
112  virtual css::awt::Size SAL_CALL getSize( ) override;
113 
114  virtual void SAL_CALL grabFocus( ) override;
115 
116  virtual sal_Int32 SAL_CALL getForeground( ) override;
117 
118  virtual sal_Int32 SAL_CALL getBackground( ) override;
119 
121 
123  virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
124 
126  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
127  getAccessibleChild(sal_Int32 nIndex) override;
128 
130  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
131  getAccessibleParent() override;
132 
134  virtual sal_Int32 SAL_CALL
135  getAccessibleIndexInParent() override;
136 
138  virtual sal_Int16 SAL_CALL
139  getAccessibleRole() override;
140 
142  virtual OUString SAL_CALL
143  getAccessibleDescription() override;
144 
146  virtual OUString SAL_CALL
147  getAccessibleName() override;
148 
150  virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
151  getAccessibleRelationSet() override;
152 
154  virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL
155  getAccessibleStateSet() override;
156 
160  virtual css::lang::Locale SAL_CALL
161  getLocale() override;
162 
164 
168  virtual void SAL_CALL
170  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
171 
172  // Remove an existing event listener.
173  virtual void SAL_CALL
175  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
176 
178 
179  virtual void SAL_CALL
180  disposing( const css::lang::EventObject& Source ) override;
181 
182  virtual void SAL_CALL
183  notifyEvent(
184  const css::accessibility::AccessibleEventObject& aEvent ) override;
185 
187 
190  virtual OUString SAL_CALL
191  getImplementationName() override;
192 
195  virtual sal_Bool SAL_CALL
196  supportsService(const OUString& sServiceName) override;
197 
201  virtual css::uno::Sequence< OUString> SAL_CALL
202  getSupportedServiceNames() override;
203 
205 
207  virtual css::uno::Sequence< css::uno::Type > SAL_CALL
208  getTypes() override;
209 
212  virtual css::uno::Sequence<sal_Int8> SAL_CALL
213  getImplementationId() override;
214 
215 protected:
219  virtual OUString
221 
225  virtual OUString
227 
232 
236  virtual tools::Rectangle GetBoundingBox() const;
237 
238 public:
240  void
241  CommitChange(const css::accessibility::AccessibleEventObject& rEvent) const;
242 
244  void SetName(const OUString& rName) { msName = rName; }
245 
247  void SetDescription(const OUString& rDesc) { msDescription = rDesc; }
248 
249  void SetParent(const css::uno::Reference<css::accessibility::XAccessible>& rParent) { mxParent = rParent; }
250 
251 protected:
253  void CommitFocusGained() const;
254 
256  void CommitFocusLost() const;
257 
258  bool IsDefunc() const { return rBHelper.bDisposed; }
259 
261  void IsObjectValid() const;
262 
264  css::uno::Reference<css::accessibility::XAccessible> mxParent;
265 
266 private:
271  OUString msDescription;
272 
276  OUString msName;
277 
279  sal_uInt32 mnClientId;
280 
283  sal_Int16 maRole;
284 };
285 
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::lang::Locale SAL_CALL getLocale() override
Return the parents locale or throw exception if this object has no parent yet/anymore.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 nIndex) override
Return the specified child or NULL if index is invalid.
OUString msDescription
Description of this object.
sal_Int32 nIndex
sal_Int16 maRole
This is the role of this object.
ScAccessibleContextBase(const css::uno::Reference< css::accessibility::XAccessible > &rxParent, const sal_Int16 aRole)
void SetDescription(const OUString &rDesc)
Use this method to set initial Description without notification.
virtual tools::Rectangle GetBoundingBox() const
Return the object's current bounding box relative to the parent object.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Return a reference to the parent.
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
Return the set of current states.
virtual OUString SAL_CALL getAccessibleName() override
Return the object's current name.
virtual void SAL_CALL release() override
virtual void SAL_CALL grabFocus() override
virtual OUString SAL_CALL getImplementationName() override
===== XServiceInfo ====================================================
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &rPoint) override
===== XAccessibleComponent ============================================
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Return NULL to indicate that an empty relation set.
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
===== XAccessibleContext ==============================================
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual css::awt::Point SAL_CALL getLocation() override
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
cppu::WeakAggComponentImplHelper5< css::accessibility::XAccessible, css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleContext, css::accessibility::XAccessibleEventBroadcaster, css::lang::XServiceInfo > ScAccessibleContextBaseWeakImpl
This base class provides an implementation of the AccessibleContext service.
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
Return this objects index among the parents children.
virtual OUString createAccessibleName()
Return the object's current name.
virtual css::awt::Rectangle SAL_CALL getBounds() override
void SetParent(const css::uno::Reference< css::accessibility::XAccessible > &rParent)
virtual OUString createAccessibleDescription()
Return this object's description.
constexpr OUStringLiteral sServiceName
void SetName(const OUString &rName)
Use this method to set initial Name without notification.
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
===== SfxListener =====================================================
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
===== XAccessibleEventBroadcaster =====================================
virtual css::awt::Size SAL_CALL getSize() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
===== XTypeProvider ===================================================
OUString msName
Name of this object.
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Return this object's role.
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
cppu::ImplHelper1< css::accessibility::XAccessibleEventListener > ScAccessibleContextBaseImplEvent
unsigned char sal_Bool
void CommitFocusGained() const
Calls all FocusListener to tell they that the focus is gained.
virtual sal_Int32 SAL_CALL getBackground() override
virtual void SAL_CALL acquire() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Returns an implementation id.
virtual tools::Rectangle GetBoundingBoxOnScreen() const
Return the object's current bounding box relative to the desktop.
sal_uInt32 mnClientId
client id in the AccessibleEventNotifier queue
virtual void SAL_CALL disposing() override
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
void CommitFocusLost() const
Calls all FocusListener to tell they that the focus is lost.
css::uno::Reference< css::accessibility::XAccessible > mxParent
Reference to the parent object.
virtual sal_Int32 SAL_CALL getForeground() override
void CommitChange(const css::accessibility::AccessibleEventObject &rEvent) const
Calls all Listener to tell they the change.
virtual ~ScAccessibleContextBase() override
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) override
===== XInterface =====================================================
AnyEventRef aEvent
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &rPoint) override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
===== XAccessible =====================================================