1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _SC_ACCESSIBLECONTEXTBASE_HXX
26cdf0e10cSrcweir #define _SC_ACCESSIBLECONTEXTBASE_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
29cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
30cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp>
31cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_IllegalAccessibleComponentStateException_HPP_
33cdf0e10cSrcweir #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
36cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
37cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
38cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
40cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
41cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
42cdf0e10cSrcweir #include <vos/mutex.hxx>
43cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <svl/lstner.hxx>
47cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
48cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
49cdf0e10cSrcweir #include <comphelper/servicehelper.hxx>
50cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir class Rectangle;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /**	@descr
55cdf0e10cSrcweir         This base class provides an implementation of the
56cdf0e10cSrcweir         <code>AccessibleContext</code> service.
57cdf0e10cSrcweir */
58cdf0e10cSrcweir 
59cdf0e10cSrcweir typedef cppu::WeakAggComponentImplHelper5<
60cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessible,
61cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessibleComponent,
62cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleContext,
63cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessibleEventBroadcaster,
64cdf0e10cSrcweir                 ::com::sun::star::lang::XServiceInfo
65cdf0e10cSrcweir 				> ScAccessibleContextBaseWeakImpl;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir typedef cppu::ImplHelper1<
68cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessibleEventListener
69cdf0e10cSrcweir 				> ScAccessibleContextBaseImplEvent;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir class ScAccessibleContextBase
72cdf0e10cSrcweir 	:	public comphelper::OBaseMutex,
73cdf0e10cSrcweir 		public ScAccessibleContextBaseWeakImpl,
74cdf0e10cSrcweir 		public ScAccessibleContextBaseImplEvent,
75cdf0e10cSrcweir 		public SfxListener
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir 	//=====  internal  ========================================================
79cdf0e10cSrcweir 	ScAccessibleContextBase(
80cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
81cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible>& rxParent,
82cdf0e10cSrcweir 		const sal_Int16 aRole);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	virtual void Init();
85cdf0e10cSrcweir     virtual void SAL_CALL disposing();
86cdf0e10cSrcweir protected:
87cdf0e10cSrcweir 	virtual ~ScAccessibleContextBase(void);
88cdf0e10cSrcweir public:
89cdf0e10cSrcweir     using WeakAggComponentImplHelperBase::addEventListener;
90cdf0e10cSrcweir     using WeakAggComponentImplHelperBase::removeEventListener;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	///=====  SfxListener  =====================================================
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	///=====  XInterface  =====================================================
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
99cdf0e10cSrcweir 		::com::sun::star::uno::Type const & rType )
100cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw ();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	virtual void SAL_CALL release() throw ();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	///=====  XAccessible  =====================================================
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     ///	Return the XAccessibleContext.
109cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
110cdf0e10cSrcweir     	getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	///=====  XAccessibleComponent  ============================================
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     virtual sal_Bool SAL_CALL containsPoint(
115cdf0e10cSrcweir 		const ::com::sun::star::awt::Point& rPoint )
116cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
119cdf0e10cSrcweir 		SAL_CALL getAccessibleAtPoint(
120cdf0e10cSrcweir 		const ::com::sun::star::awt::Point& rPoint )
121cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  )
124cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  )
127cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  )
130cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  )
133cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isShowing(  )
136cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isVisible(  )
139cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     virtual void SAL_CALL grabFocus(  )
142cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getForeground(  )
145cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getBackground(  )
148cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     ///=====  XAccessibleContext  ==============================================
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     ///	Return the number of currently visible children.
153cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
154cdf0e10cSrcweir     	getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     ///	Return the specified child or NULL if index is invalid.
157cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
158cdf0e10cSrcweir     	getAccessibleChild(sal_Int32 nIndex)
159cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
160cdf0e10cSrcweir 				::com::sun::star::lang::IndexOutOfBoundsException);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     ///	Return a reference to the parent.
163cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
164cdf0e10cSrcweir     	getAccessibleParent(void)
165cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     ///	Return this objects index among the parents children.
168cdf0e10cSrcweir 	virtual	sal_Int32 SAL_CALL
169cdf0e10cSrcweir     	getAccessibleIndexInParent(void)
170cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     ///	Return this object's role.
173cdf0e10cSrcweir 	virtual sal_Int16 SAL_CALL
174cdf0e10cSrcweir     	getAccessibleRole(void)
175cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     ///	Return this object's description.
178cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
179cdf0e10cSrcweir     	getAccessibleDescription(void)
180cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     ///	Return the object's current name.
183cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
184cdf0e10cSrcweir     	getAccessibleName(void)
185cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	///	Return NULL to indicate that an empty relation set.
188cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
189cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
190cdf0e10cSrcweir     	getAccessibleRelationSet(void)
191cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     ///	Return the set of current states.
194cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
195cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
196cdf0e10cSrcweir     	getAccessibleStateSet(void)
197cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	/**	Return the parents locale or throw exception if this object has no
200cdf0e10cSrcweir     	parent yet/anymore.
201cdf0e10cSrcweir     */
202cdf0e10cSrcweir 	virtual ::com::sun::star::lang::Locale SAL_CALL
203cdf0e10cSrcweir     	getLocale(void)
204cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException,
205cdf0e10cSrcweir 			::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	///=====  XAccessibleEventBroadcaster  =====================================
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     /**	Add listener that is informed of future changes of name,
210cdf0e10cSrcweir       	description and so on events.
211cdf0e10cSrcweir     */
212cdf0e10cSrcweir 	virtual void SAL_CALL
213cdf0e10cSrcweir     	addEventListener(
214cdf0e10cSrcweir         	const ::com::sun::star::uno::Reference<
215cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
216cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     //	Remove an existing event listener.
219cdf0e10cSrcweir 	virtual void SAL_CALL
220cdf0e10cSrcweir     	removeEventListener(
221cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference<
222cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
223cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	///=====  XAccessibleEventListener  ========================================
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     virtual void SAL_CALL
228cdf0e10cSrcweir 		disposing( const ::com::sun::star::lang::EventObject& Source )
229cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	virtual void SAL_CALL
232cdf0e10cSrcweir 		notifyEvent(
233cdf0e10cSrcweir 		const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
234cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	///=====  XServiceInfo  ====================================================
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     /**	Returns an identifier for the implementation of this object.
239cdf0e10cSrcweir     */
240cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
241cdf0e10cSrcweir     	getImplementationName(void)
242cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     /**	Return whether the specified service is supported by this class.
245cdf0e10cSrcweir     */
246cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
247cdf0e10cSrcweir     	supportsService(const ::rtl::OUString& sServiceName)
248cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     /** Returns a list of all supported services.  In this case that is just
251cdf0e10cSrcweir     	the AccessibleContext and Accessible service.
252cdf0e10cSrcweir     */
253cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
254cdf0e10cSrcweir     	getSupportedServiceNames(void)
255cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 	///=====  XTypeProvider  ===================================================
258cdf0e10cSrcweir 
259cdf0e10cSrcweir  	/// returns the possible types
260cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
261cdf0e10cSrcweir 		getTypes()
262cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	/**	Returns a implementation id.
265cdf0e10cSrcweir     */
266cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
267cdf0e10cSrcweir         getImplementationId(void)
268cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
269cdf0e10cSrcweir 
270cdf0e10cSrcweir protected:
271cdf0e10cSrcweir     ///	Return this object's description.
272cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
273cdf0e10cSrcweir     	createAccessibleDescription(void)
274cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     ///	Return the object's current name.
277cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
278cdf0e10cSrcweir     	createAccessibleName(void)
279cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     ///	Return the object's current bounding box relative to the desktop.
282cdf0e10cSrcweir 	virtual Rectangle GetBoundingBoxOnScreen(void) const
283cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	///	Return the object's current bounding box relative to the parent object.
286cdf0e10cSrcweir 	virtual Rectangle GetBoundingBox(void) const
287cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
288cdf0e10cSrcweir 
289cdf0e10cSrcweir public:
290cdf0e10cSrcweir     /// Calls all Listener to tell they the change.
291cdf0e10cSrcweir 	void
292cdf0e10cSrcweir 		CommitChange(const com::sun::star::accessibility::AccessibleEventObject& rEvent) const;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     /// change the name and call the listener to tell they the change
295cdf0e10cSrcweir     void
296cdf0e10cSrcweir         ChangeName();
297cdf0e10cSrcweir 
298cdf0e10cSrcweir protected:
299cdf0e10cSrcweir 	/// Calls all FocusListener to tell they that the focus is gained.
300cdf0e10cSrcweir 	void CommitFocusGained() const;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	/// Calls all FocusListener to tell they that the focus is lost.
303cdf0e10cSrcweir 	void CommitFocusLost() const;
304cdf0e10cSrcweir 
IsDefunc() const305cdf0e10cSrcweir 	sal_Bool IsDefunc() const { return rBHelper.bDisposed; }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     virtual void IsObjectValid() const
308cdf0e10cSrcweir         throw (::com::sun::star::lang::DisposedException);
309cdf0e10cSrcweir 
310cdf0e10cSrcweir     /// Use this method to set initial Name without notification
SetName(const rtl::OUString & rName)311cdf0e10cSrcweir     void SetName(const rtl::OUString& rName) { msName = rName; }
312cdf0e10cSrcweir     /// Use this method to set initial Description without notification
SetDescription(const rtl::OUString & rDesc)313cdf0e10cSrcweir     void SetDescription(const rtl::OUString& rDesc) { msDescription = rDesc; }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     ///	Reference to the parent object.
316cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
317cdf0e10cSrcweir     	 ::com::sun::star::accessibility::XAccessible> mxParent;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir private:
320cdf0e10cSrcweir     /**	Description of this object.  This is not a constant because it can
321cdf0e10cSrcweir     	be set from the outside.  Furthermore, it changes according the the
322cdf0e10cSrcweir         draw page's display mode.
323cdf0e10cSrcweir     */
324cdf0e10cSrcweir     ::rtl::OUString msDescription;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     /**	Name of this object.  It changes according the the draw page's
327cdf0e10cSrcweir         display mode.
328cdf0e10cSrcweir     */
329cdf0e10cSrcweir     ::rtl::OUString msName;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     /// client id in the AccessibleEventNotifier queue
332cdf0e10cSrcweir     sal_uInt32 mnClientId;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	/** This is the role of this object.
335cdf0e10cSrcweir 	*/
336cdf0e10cSrcweir 	sal_Int16 maRole;
337cdf0e10cSrcweir };
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 
340cdf0e10cSrcweir #endif
341