remove assert looking for new compatibilityMode DOCX
[LibreOffice.git] / include / comphelper / accessiblecomponenthelper.hxx
blob55cb5703d596dc97929dc35c9d005cea84ecc277
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_COMPHELPER_ACCESSIBLECOMPONENTHELPER_HXX
21 #define INCLUDED_COMPHELPER_ACCESSIBLECOMPONENTHELPER_HXX
23 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
24 #include <com/sun/star/accessibility/XAccessibleContext2.hpp>
25 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
26 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
27 #include <comphelper/accessibleeventnotifier.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <cppuhelper/compbase.hxx>
30 #include <cppuhelper/implbase.hxx>
31 #include <comphelper/comphelperdllapi.h>
34 namespace comphelper
38 //= OCommonAccessibleComponent
40 typedef ::cppu::WeakComponentImplHelper < css::accessibility::XAccessibleContext2,
41 css::accessibility::XAccessibleEventBroadcaster
42 > OCommonAccessibleComponent_Base;
44 /** base class encapsulating common functionality for the helper classes implementing
45 the XAccessibleComponent respectively XAccessibleExtendendComponent
47 class COMPHELPER_DLLPUBLIC OCommonAccessibleComponent
48 :public ::cppu::BaseMutex
49 ,public OCommonAccessibleComponent_Base
51 friend class OContextEntryGuard;
52 private:
53 AccessibleEventNotifier::TClientId m_nClientId;
55 protected:
56 virtual ~OCommonAccessibleComponent( ) override;
58 OCommonAccessibleComponent( );
60 public:
61 // XAccessibleEventBroadcaster
62 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override final;
63 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override final;
65 // XAccessibleContext - still waiting to be overwritten
66 virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override = 0;
67 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override = 0;
68 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override = 0;
69 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override = 0;
70 virtual OUString SAL_CALL getAccessibleDescription( ) override = 0;
71 virtual OUString SAL_CALL getAccessibleName( ) override = 0;
72 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override = 0;
73 virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override = 0;
75 // XAccessibleContext2 - default implementation
76 virtual OUString SAL_CALL getAccessibleId( ) override;
78 // XAccessibleContext - default implementations
79 /** default implementation for retrieving the index of this object within the parent
80 <p>This basic implementation here returns the index <code>i</code> of the child for which
81 <code>&lt;parent&gt;.getAccessibleChild(i).getAccessibleContext()</code> returns
82 a reference to this OCommonAccessibleComponent object.</p>
84 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override;
85 /** default implementation for retrieving the locale
86 <p>This basic implementation returns the locale of the parent context,
87 as retrieved via getAccessibleParent()->getAccessibleContext.</p>
89 virtual css::lang::Locale SAL_CALL getLocale( ) override;
91 protected:
92 // OComponentHelper
93 virtual void SAL_CALL disposing() override;
95 protected:
96 // helper
97 /** notifies all AccessibleEventListeners of a certain event
99 @precond not to be called with our mutex locked
100 @param _nEventId
101 the id of the event. See AccessibleEventType
102 @param _rOldValue
103 the old value to be notified
104 @param _rNewValue
105 the new value to be notified
107 void NotifyAccessibleEvent(
108 const sal_Int16 _nEventId,
109 const css::uno::Any& _rOldValue,
110 const css::uno::Any& _rNewValue,
111 sal_Int32 nIndexHint = -1
114 // life time control
115 /// checks whether the object is alive (returns <TRUE/> then) or disposed
116 bool isAlive() const;
117 /// checks for being alive. If the object is already disposed (i.e. not alive), an exception is thrown.
118 void ensureAlive() const;
120 /** ensures that the object is disposed.
121 @precond
122 to be called from within the destructor of your derived class only!
124 void ensureDisposed( );
126 /** shortcut for retrieving the context of the parent (returned by getAccessibleParent)
128 css::uno::Reference< css::accessibility::XAccessibleContext >
129 implGetParentContext();
131 // access to the base class' broadcast helper/mutex
132 ::osl::Mutex& GetMutex() { return m_aMutex; }
134 protected:
135 /// implements the calculation of the bounding rectangle - still waiting to be overwritten
137 /// @throws css::uno::RuntimeException
138 virtual css::awt::Rectangle implGetBounds( ) = 0;
140 protected:
141 /** non-virtual versions of the methods which can be implemented using <method>implGetBounds</method>
142 note: getLocationOnScreen relies on a valid parent (XAccessibleContext::getParent()->getAccessibleContext()),
143 which itself implements XAccessibleComponent
145 @throws css::uno::RuntimeException
147 bool containsPoint( const css::awt::Point& aPoint );
148 /// @throws css::uno::RuntimeException
149 css::awt::Point getLocation( );
150 /// @throws css::uno::RuntimeException
151 css::awt::Point getLocationOnScreen( );
152 /// @throws css::uno::RuntimeException
153 css::awt::Size getSize( );
154 /// @throws css::uno::RuntimeException
155 css::awt::Rectangle getBounds( );
159 //= OAccessibleComponentHelper
162 /** a helper class for implementing an AccessibleContext which at the same time
163 supports an XAccessibleComponent interface.
165 class COMPHELPER_DLLPUBLIC OAccessibleComponentHelper
166 :public cppu::ImplInheritanceHelper<
167 OCommonAccessibleComponent, css::accessibility::XAccessibleComponent>
169 private:
170 OAccessibleComponentHelper(OAccessibleComponentHelper const &) = delete;
171 OAccessibleComponentHelper(OAccessibleComponentHelper &&) = delete;
172 void operator =(OAccessibleComponentHelper const &) = delete;
173 void operator =(OAccessibleComponentHelper &&) = delete;
175 protected:
176 OAccessibleComponentHelper();
178 public:
179 // XAccessibleComponent - default implementations
180 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override final;
181 virtual css::awt::Point SAL_CALL getLocation( ) override final;
182 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
183 virtual css::awt::Size SAL_CALL getSize( ) override final;
184 virtual css::awt::Rectangle SAL_CALL getBounds( ) override final;
188 //= OAccessibleExtendedComponentHelper
191 /** a helper class for implementing an AccessibleContext which at the same time
192 supports an XAccessibleExtendedComponent interface.
194 class COMPHELPER_DLLPUBLIC OAccessibleExtendedComponentHelper
195 :public cppu::ImplInheritanceHelper<
196 OCommonAccessibleComponent, css::accessibility::XAccessibleExtendedComponent>
198 private:
199 OAccessibleExtendedComponentHelper(OAccessibleExtendedComponentHelper const &) = delete;
200 OAccessibleExtendedComponentHelper(OAccessibleExtendedComponentHelper &&) = delete;
201 void operator =(OAccessibleExtendedComponentHelper const &) = delete;
202 void operator =(OAccessibleExtendedComponentHelper &&) = delete;
204 protected:
205 OAccessibleExtendedComponentHelper( );
207 public:
208 // XAccessibleComponent - default implementations
209 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override final;
210 virtual css::awt::Point SAL_CALL getLocation( ) override;
211 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
212 virtual css::awt::Size SAL_CALL getSize( ) override;
213 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
217 } // namespace comphelper
220 #endif // INCLUDED_COMPHELPER_ACCESSIBLECOMPONENTHELPER_HXX
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */