update dev300-m58
[ooovba.git] / svx / source / inc / GraphCtlAccessibleContext.hxx
blob85923590f3a4779821682f8070c45953c100b012
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: GraphCtlAccessibleContext.hxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _SVXGRAPHACCESSIBLECONTEXT_HXX
33 #define _SVXGRAPHACCESSIBLECONTEXT_HXX
35 #ifndef _CPPUHELPER_IMPLBASE7_HXX_
36 #include <cppuhelper/compbase7.hxx>
37 #endif
38 #include <com/sun/star/uno/Reference.hxx>
39 #include <com/sun/star/accessibility/XAccessible.hpp>
40 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
41 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
42 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
43 #ifndef _COM_SUN_STAR_ACCESSIBILITY_IllegalAccessibleComponentStateException_HPP_
44 #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
45 #endif
46 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
47 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
48 #include <cppuhelper/weak.hxx>
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/lang/XTypeProvider.hpp>
51 #include <com/sun/star/lang/XServiceName.hpp>
52 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
53 #include <vos/mutex.hxx>
54 #include <comphelper/broadcasthelper.hxx>
55 #include <svtools/lstner.hxx>
57 #include <set>
58 #include <map>
60 #include <comphelper/servicehelper.hxx>
61 #include <svx/rectenum.hxx>
62 #include <svx/AccessibleShapeTreeInfo.hxx>
63 #include <svx/IAccessibleViewForwarder.hxx>
64 #include <svx/AccessibleShape.hxx>
66 namespace com { namespace sun { namespace star { namespace awt {
67 struct Point;
68 struct Rectangle;
69 struct Size;
70 class XFocusListener;
71 } } } }
73 class Rectangle;
74 class GraphCtrl;
75 class Window;
76 class SdrObject;
77 class SdrModel;
78 class SdrPage;
79 class SdrView;
81 /** @descr
82 This base class provides an implementation of the
83 <code>AccessibleContext</code> service.
86 typedef ::cppu::WeakAggComponentImplHelper7<
87 ::com::sun::star::accessibility::XAccessible,
88 ::com::sun::star::accessibility::XAccessibleComponent,
89 ::com::sun::star::accessibility::XAccessibleContext,
90 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
91 ::com::sun::star::accessibility::XAccessibleSelection,
92 ::com::sun::star::lang::XServiceInfo,
93 ::com::sun::star::lang::XServiceName >
94 SvxGraphCtrlAccessibleContext_Base;
96 class SvxGraphCtrlAccessibleContext : public SvxGraphCtrlAccessibleContext_Base, ::comphelper::OBaseMutex, SfxListener, ::accessibility::IAccessibleViewForwarder
98 public:
99 friend class GraphCtrl;
101 //===== internal ========================================================
102 SvxGraphCtrlAccessibleContext(
103 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
104 GraphCtrl& rRepresentation,
105 const ::rtl::OUString* pName = NULL,
106 const ::rtl::OUString* pDescription = NULL );
108 void Notify( SfxBroadcaster& aBC, const SfxHint& aHint );
110 protected:
111 virtual ~SvxGraphCtrlAccessibleContext();
112 public:
113 //===== XAccessible =====================================================
115 /// Return the XAccessibleContext.
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
117 getAccessibleContext (void) throw (::com::sun::star::uno::RuntimeException);
119 //===== XAccessibleComponent ============================================
121 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException);
122 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);
123 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException);
124 virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException);
125 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException);
126 virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException);
127 virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
128 virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
129 virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
130 virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() throw (::com::sun::star::uno::RuntimeException);
132 virtual sal_Int32 SAL_CALL getForeground (void)
133 throw (::com::sun::star::uno::RuntimeException);
135 virtual sal_Int32 SAL_CALL getBackground (void)
136 throw (::com::sun::star::uno::RuntimeException);
139 //===== XAccessibleContext ==============================================
141 virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
142 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);
143 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException);
144 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException);
145 virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException);
146 virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException);
147 virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException);
148 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet (void) throw (::com::sun::star::uno::RuntimeException);
149 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet (void) throw (::com::sun::star::uno::RuntimeException);
150 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale (void) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
151 // virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
152 // virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
154 //===== XComponent ========================================================
156 using ::cppu::WeakAggComponentImplHelperBase::addEventListener;
157 using ::cppu::WeakAggComponentImplHelperBase::removeEventListener;
159 //===== XAccessibleEventBroadcaster =====================================
161 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException);
162 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException);
164 //===== XServiceInfo ====================================================
166 virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException);
167 virtual sal_Bool SAL_CALL supportsService (const ::rtl::OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException);
168 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException);
170 //===== XTypeProvider ===================================================
172 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId (void) throw (::com::sun::star::uno::RuntimeException);
174 //===== XServiceName ====================================================
176 virtual ::rtl::OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException);
178 //===== XAccessibleSelection =============================================
180 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
181 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
182 virtual void SAL_CALL clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException );
183 virtual void SAL_CALL selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException );
184 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException );
185 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 );
186 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
188 //===== IAccessibleViewforwarder ========================================
190 virtual BOOL IsValid (void) const;
191 virtual Rectangle GetVisibleArea() const;
192 virtual Point LogicToPixel (const Point& rPoint) const;
193 virtual Size LogicToPixel (const Size& rSize) const;
194 virtual Point PixelToLogic (const Point& rPoint) const;
195 virtual Size PixelToLogic (const Size& rSize) const;
197 protected:
198 //===== internals ========================================================
200 void checkChildIndex( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
201 void checkChildIndexOnSelection( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
203 public:
205 /// Sets the name
206 void setName( const ::rtl::OUString& rName );
208 /// Sets the description
209 void setDescription( const ::rtl::OUString& rDescr );
211 /** This method is used by the graph control to tell the
212 accessibility object about a new model and view.
214 void setModelAndView (SdrModel* pModel, SdrView* pView);
216 private:
217 static ::com::sun::star::uno::Sequence< sal_Int8 > getUniqueId( void );
218 protected:
220 /** Return the object's current bounding box relative to the desktop,
221 i.e in absolute pixel coordinates.
222 @return
223 The returned rectangle is a bounding box of the object given in
224 absolute screen coordinates.
225 @raise DisposedException
226 When the object is already disposed then a
227 <type>DisposedException</type> is thrown.
229 virtual Rectangle GetBoundingBoxOnScreen(void) throw (::com::sun::star::uno::RuntimeException);
231 /// Return the object's current bounding box relative to the parent object.
232 virtual Rectangle GetBoundingBox(void) throw (::com::sun::star::uno::RuntimeException);
234 virtual void SAL_CALL disposing();
236 private:
237 SdrObject* getSdrObject( sal_Int32 nIndex )
238 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
240 void CommitChange (sal_Int16 aEventId, const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue);
241 void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject& aEvent);
243 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessible( const SdrObject* pObj );
245 accessibility::AccessibleShapeTreeInfo maTreeInfo;
247 /// Reference to the parent object.
248 ::com::sun::star::uno::Reference<
249 ::com::sun::star::accessibility::XAccessible> mxParent;
251 /** Description of this object. This is not a constant because it can
252 be set from the outside.
254 ::rtl::OUString msDescription;
256 /** Name of this object.
258 ::rtl::OUString msName;
260 /// map of accessible shapes
261 struct SdrObjectCompareLess
263 bool operator()(const SdrObject* p1, const SdrObject* p2) const
265 return p1 < p2;
268 typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType;
269 ShapesMapType mxShapes;
271 GraphCtrl* mpControl;
273 SdrModel* mpModel;
274 SdrPage* mpPage;
275 SdrView* mpView;
277 /// client id in the AccessibleEventNotifier queue
278 sal_uInt32 mnClientId;
280 sal_Bool mbDisposed;
283 #endif