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 #ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX
22 
23 #include <com/sun/star/accessibility/XAccessible.hpp>
24 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
25 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
30 
31 #include <svl/lstner.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 #include <cppuhelper/compbase5.hxx>
34 #include <cppuhelper/implbase1.hxx>
35 
36 namespace tools { class Rectangle; }
37 
44  css::accessibility::XAccessible,
45  css::accessibility::XAccessibleComponent,
46  css::accessibility::XAccessibleContext,
47  css::accessibility::XAccessibleEventBroadcaster,
48  css::lang::XServiceInfo
50 
51 typedef cppu::ImplHelper1<
52  css::accessibility::XAccessibleEventListener
54 
56  : public cppu::BaseMutex,
59  public SfxListener
60 {
61 public:
62  //===== internal ========================================================
64  const css::uno::Reference<css::accessibility::XAccessible>& rxParent,
65  const sal_Int16 aRole);
66 
67  virtual void Init();
68  virtual void SAL_CALL disposing() override;
69 protected:
70  virtual ~ScAccessibleContextBase() override;
71 public:
72 
74  bool isShowing();
75 
77  virtual bool isVisible();
78 
80 
81  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
82 
84 
85  virtual css::uno::Any SAL_CALL queryInterface(
86  css::uno::Type const & rType ) override;
87 
88  virtual void SAL_CALL acquire() throw () override;
89 
90  virtual void SAL_CALL release() throw () override;
91 
93 
95  virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL
96  getAccessibleContext() override;
97 
99 
100  virtual sal_Bool SAL_CALL containsPoint(
101  const css::awt::Point& rPoint ) override;
102 
103  virtual css::uno::Reference< css::accessibility::XAccessible >
104  SAL_CALL getAccessibleAtPoint(
105  const css::awt::Point& rPoint ) override;
106 
107  virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
108 
109  virtual css::awt::Point SAL_CALL getLocation( ) override;
110 
111  virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
112 
113  virtual css::awt::Size SAL_CALL getSize( ) override;
114 
115  virtual void SAL_CALL grabFocus( ) override;
116 
117  virtual sal_Int32 SAL_CALL getForeground( ) override;
118 
119  virtual sal_Int32 SAL_CALL getBackground( ) override;
120 
122 
124  virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
125 
127  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
128  getAccessibleChild(sal_Int32 nIndex) override;
129 
131  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
132  getAccessibleParent() override;
133 
135  virtual sal_Int32 SAL_CALL
136  getAccessibleIndexInParent() override;
137 
139  virtual sal_Int16 SAL_CALL
140  getAccessibleRole() override;
141 
143  virtual OUString SAL_CALL
144  getAccessibleDescription() override;
145 
147  virtual OUString SAL_CALL
148  getAccessibleName() override;
149 
151  virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
152  getAccessibleRelationSet() override;
153 
155  virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL
156  getAccessibleStateSet() override;
157 
161  virtual css::lang::Locale SAL_CALL
162  getLocale() override;
163 
165 
169  virtual void SAL_CALL
171  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
172 
173  // Remove an existing event listener.
174  virtual void SAL_CALL
176  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
177 
179 
180  virtual void SAL_CALL
181  disposing( const css::lang::EventObject& Source ) override;
182 
183  virtual void SAL_CALL
184  notifyEvent(
185  const css::accessibility::AccessibleEventObject& aEvent ) override;
186 
188 
191  virtual OUString SAL_CALL
192  getImplementationName() override;
193 
196  virtual sal_Bool SAL_CALL
197  supportsService(const OUString& sServiceName) override;
198 
202  virtual css::uno::Sequence< OUString> SAL_CALL
203  getSupportedServiceNames() override;
204 
206 
208  virtual css::uno::Sequence< css::uno::Type > SAL_CALL
209  getTypes() override;
210 
213  virtual css::uno::Sequence<sal_Int8> SAL_CALL
214  getImplementationId() override;
215 
216 protected:
220  virtual OUString
222 
226  virtual OUString
228 
233 
237  virtual tools::Rectangle GetBoundingBox() const;
238 
239 public:
241  void
242  CommitChange(const css::accessibility::AccessibleEventObject& rEvent) const;
243 
245  void SetName(const OUString& rName) { msName = rName; }
246 
248  void SetDescription(const OUString& rDesc) { msDescription = rDesc; }
249 
250  void SetParent(const css::uno::Reference<css::accessibility::XAccessible>& rParent) { mxParent = rParent; }
251 
252 protected:
254  void CommitFocusGained() const;
255 
257  void CommitFocusLost() const;
258 
259  bool IsDefunc() const { return rBHelper.bDisposed; }
260 
262  void IsObjectValid() const;
263 
265  css::uno::Reference<css::accessibility::XAccessible> mxParent;
266 
267 private:
272  OUString msDescription;
273 
277  OUString msName;
278 
280  sal_uInt32 mnClientId;
281 
284  sal_Int16 maRole;
285 };
286 
287 #endif
288 
289 /* 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.
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
const char sServiceName[]
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 =====================================================