xref: /AOO41X/main/svx/source/inc/GraphCtlAccessibleContext.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
1*3334a7e6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3334a7e6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3334a7e6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3334a7e6SAndrew Rist  * distributed with this work for additional information
6*3334a7e6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3334a7e6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3334a7e6SAndrew Rist  * "License"); you may not use this file except in compliance
9*3334a7e6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*3334a7e6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*3334a7e6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3334a7e6SAndrew Rist  * software distributed under the License is distributed on an
15*3334a7e6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3334a7e6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3334a7e6SAndrew Rist  * specific language governing permissions and limitations
18*3334a7e6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*3334a7e6SAndrew Rist  *************************************************************/
21*3334a7e6SAndrew Rist 
22*3334a7e6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _SVXGRAPHACCESSIBLECONTEXT_HXX
26cdf0e10cSrcweir #define _SVXGRAPHACCESSIBLECONTEXT_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE7_HXX_
29cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
32cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
33cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
34cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp>
35cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_IllegalAccessibleComponentStateException_HPP_
37cdf0e10cSrcweir #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
40cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp>
41cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
42cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
46cdf0e10cSrcweir #include <vos/mutex.hxx>
47cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
48cdf0e10cSrcweir #include <svl/lstner.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <set>
51cdf0e10cSrcweir #include <map>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include <comphelper/servicehelper.hxx>
54cdf0e10cSrcweir #include <svx/rectenum.hxx>
55cdf0e10cSrcweir #include <svx/AccessibleShapeTreeInfo.hxx>
56cdf0e10cSrcweir #include <svx/IAccessibleViewForwarder.hxx>
57cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace awt {
60cdf0e10cSrcweir 	struct Point;
61cdf0e10cSrcweir 	struct Rectangle;
62cdf0e10cSrcweir 	struct Size;
63cdf0e10cSrcweir 	class XFocusListener;
64cdf0e10cSrcweir } } } }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir class Rectangle;
67cdf0e10cSrcweir class GraphCtrl;
68cdf0e10cSrcweir class Window;
69cdf0e10cSrcweir class SdrObject;
70cdf0e10cSrcweir class SdrModel;
71cdf0e10cSrcweir class SdrPage;
72cdf0e10cSrcweir class SdrView;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir /**	@descr
75cdf0e10cSrcweir         This base class provides an implementation of the
76cdf0e10cSrcweir         <code>AccessibleContext</code> service.
77cdf0e10cSrcweir */
78cdf0e10cSrcweir 
79cdf0e10cSrcweir typedef ::cppu::WeakAggComponentImplHelper7<
80cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessible,
81cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessibleComponent,
82cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleContext,
83cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessibleEventBroadcaster,
84cdf0e10cSrcweir 				::com::sun::star::accessibility::XAccessibleSelection,
85cdf0e10cSrcweir                 ::com::sun::star::lang::XServiceInfo,
86cdf0e10cSrcweir                 ::com::sun::star::lang::XServiceName >
87cdf0e10cSrcweir 				SvxGraphCtrlAccessibleContext_Base;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir class SvxGraphCtrlAccessibleContext : public SvxGraphCtrlAccessibleContext_Base, ::comphelper::OBaseMutex, SfxListener, ::accessibility::IAccessibleViewForwarder
90cdf0e10cSrcweir {
91cdf0e10cSrcweir public:
92cdf0e10cSrcweir 	friend class GraphCtrl;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	//=====  internal  ========================================================
95cdf0e10cSrcweir 	SvxGraphCtrlAccessibleContext(
96cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
97cdf0e10cSrcweir 		GraphCtrl&				rRepresentation,
98cdf0e10cSrcweir 		const ::rtl::OUString*	pName = NULL,
99cdf0e10cSrcweir 		const ::rtl::OUString*	pDescription = NULL );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	void Notify( SfxBroadcaster& aBC, const	SfxHint& aHint );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir protected:
104cdf0e10cSrcweir 	virtual ~SvxGraphCtrlAccessibleContext();
105cdf0e10cSrcweir public:
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( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint )	throw (::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir     virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir     virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir     virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir 	virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
122cdf0e10cSrcweir     virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() throw (::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getForeground (void)
126cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getBackground (void)
129cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	//=====  XAccessibleContext  ==============================================
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int32 nIndex) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException);
136cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir 	virtual	sal_Int32 SAL_CALL getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException);
138cdf0e10cSrcweir 	virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException);
139cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException);
140cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet (void) throw (::com::sun::star::uno::RuntimeException);
142cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet (void) throw (::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir 	virtual ::com::sun::star::lang::Locale SAL_CALL	getLocale (void) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
144cdf0e10cSrcweir //	virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
145cdf0e10cSrcweir //  virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     //=====  XComponent  ========================================================
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	using ::cppu::WeakAggComponentImplHelperBase::addEventListener;
150cdf0e10cSrcweir     using ::cppu::WeakAggComponentImplHelperBase::removeEventListener;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	//=====  XAccessibleEventBroadcaster  =====================================
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir 	virtual void SAL_CALL removeEventListener(	const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	//=====  XServiceInfo  ====================================================
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException);
160cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService (const ::rtl::OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException);
161cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	//=====  XTypeProvider  ===================================================
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId (void) throw (::com::sun::star::uno::RuntimeException);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     //=====  XServiceName  ====================================================
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	//=====  XAccessibleSelection =============================================
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
174cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
175cdf0e10cSrcweir     virtual void SAL_CALL clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException );
176cdf0e10cSrcweir     virtual void SAL_CALL selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException );
177cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException );
178cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
179cdf0e10cSrcweir 	virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     //=====  IAccessibleViewforwarder  ========================================
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 	virtual sal_Bool IsValid (void) const;
184cdf0e10cSrcweir     virtual Rectangle GetVisibleArea() const;
185cdf0e10cSrcweir     virtual Point LogicToPixel (const Point& rPoint) const;
186cdf0e10cSrcweir     virtual Size LogicToPixel (const Size& rSize) const;
187cdf0e10cSrcweir     virtual Point PixelToLogic (const Point& rPoint) const;
188cdf0e10cSrcweir     virtual Size PixelToLogic (const Size& rSize) const;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir protected:
191cdf0e10cSrcweir 	//=====  internals ========================================================
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	void checkChildIndex( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
194cdf0e10cSrcweir 	void checkChildIndexOnSelection( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir public:
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	/// Sets the name
199cdf0e10cSrcweir 	void setName( const ::rtl::OUString& rName );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	/// Sets the description
202cdf0e10cSrcweir 	void setDescription( const ::rtl::OUString& rDescr );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     /** This method is used by the graph control to tell the
205cdf0e10cSrcweir         accessibility object about a new model and view.
206cdf0e10cSrcweir     */
207cdf0e10cSrcweir     void setModelAndView (SdrModel* pModel, SdrView* pView);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir private:
210cdf0e10cSrcweir 	static ::com::sun::star::uno::Sequence< sal_Int8 > getUniqueId( void );
211cdf0e10cSrcweir protected:
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     /**	Return the object's current bounding box relative to the desktop,
214cdf0e10cSrcweir         i.e in absolute pixel coordinates.
215cdf0e10cSrcweir         @return
216cdf0e10cSrcweir             The returned rectangle is a bounding box of the object given in
217cdf0e10cSrcweir             absolute screen coordinates.
218cdf0e10cSrcweir         @raise DisposedException
219cdf0e10cSrcweir             When the object is already disposed then a
220cdf0e10cSrcweir             <type>DisposedException</type> is thrown.
221cdf0e10cSrcweir     */
222cdf0e10cSrcweir  	virtual Rectangle GetBoundingBoxOnScreen(void) throw (::com::sun::star::uno::RuntimeException);
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	///	Return the object's current bounding box relative to the parent object.
225cdf0e10cSrcweir 	virtual Rectangle GetBoundingBox(void) throw (::com::sun::star::uno::RuntimeException);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
228cdf0e10cSrcweir 
229cdf0e10cSrcweir private:
230cdf0e10cSrcweir 	SdrObject* getSdrObject( sal_Int32 nIndex )
231cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	void CommitChange (sal_Int16 aEventId, const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue);
234cdf0e10cSrcweir 	void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject& aEvent);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessible( const SdrObject* pObj );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	accessibility::AccessibleShapeTreeInfo maTreeInfo;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     ///	Reference to the parent object.
241cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
242cdf0e10cSrcweir     	 ::com::sun::star::accessibility::XAccessible> mxParent;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     /**	Description of this object.  This is not a constant because it can
245cdf0e10cSrcweir     	be set from the outside.
246cdf0e10cSrcweir     */
247cdf0e10cSrcweir     ::rtl::OUString msDescription;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     /**	Name of this object.
250cdf0e10cSrcweir     */
251cdf0e10cSrcweir     ::rtl::OUString msName;
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     ///	map of accessible shapes
254cdf0e10cSrcweir 	struct SdrObjectCompareLess
255cdf0e10cSrcweir 	{
operator ()SvxGraphCtrlAccessibleContext::SdrObjectCompareLess256cdf0e10cSrcweir 		bool operator()(const SdrObject* p1, const SdrObject* p2) const
257cdf0e10cSrcweir 		{
258cdf0e10cSrcweir 			return p1 < p2;
259cdf0e10cSrcweir 		}
260cdf0e10cSrcweir 	};
261cdf0e10cSrcweir 	typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType;
262cdf0e10cSrcweir 	ShapesMapType mxShapes;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	GraphCtrl*	mpControl;
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	SdrModel* mpModel;
267cdf0e10cSrcweir 	SdrPage* mpPage;
268cdf0e10cSrcweir 	SdrView* mpView;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     /// client id in the AccessibleEventNotifier queue
271cdf0e10cSrcweir     sal_uInt32 mnClientId;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	sal_Bool mbDisposed;
274cdf0e10cSrcweir };
275cdf0e10cSrcweir 
276cdf0e10cSrcweir #endif
277cdf0e10cSrcweir 
278