Line data Source code
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 :
21 : #ifndef INCLUDED_SVX_SOURCE_INC_GRAPHCTLACCESSIBLECONTEXT_HXX
22 : #define INCLUDED_SVX_SOURCE_INC_GRAPHCTLACCESSIBLECONTEXT_HXX
23 :
24 : #include <cppuhelper/compbase7.hxx>
25 : #include <com/sun/star/uno/Reference.hxx>
26 : #include <com/sun/star/accessibility/XAccessible.hpp>
27 : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
28 : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
29 : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
30 : #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
31 : #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
32 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
33 : #include <cppuhelper/weak.hxx>
34 : #include <com/sun/star/lang/XServiceInfo.hpp>
35 : #include <com/sun/star/lang/XTypeProvider.hpp>
36 : #include <com/sun/star/lang/XServiceName.hpp>
37 : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
38 : #include <osl/mutex.hxx>
39 : #include <comphelper/broadcasthelper.hxx>
40 : #include <svl/lstner.hxx>
41 :
42 : #include <set>
43 : #include <map>
44 :
45 : #include <comphelper/servicehelper.hxx>
46 : #include <svx/rectenum.hxx>
47 : #include <svx/AccessibleShapeTreeInfo.hxx>
48 : #include <svx/IAccessibleViewForwarder.hxx>
49 : #include <svx/AccessibleShape.hxx>
50 :
51 : namespace com { namespace sun { namespace star { namespace awt {
52 : struct Point;
53 : struct Rectangle;
54 : struct Size;
55 : class XFocusListener;
56 : } } } }
57 :
58 : class Rectangle;
59 : class GraphCtrl;
60 : class SdrObject;
61 : class SdrModel;
62 : class SdrPage;
63 : class SdrView;
64 :
65 : /** @descr
66 : This base class provides an implementation of the
67 : <code>AccessibleContext</code> service.
68 : */
69 :
70 : typedef ::cppu::WeakAggComponentImplHelper7<
71 : ::com::sun::star::accessibility::XAccessible,
72 : ::com::sun::star::accessibility::XAccessibleComponent,
73 : ::com::sun::star::accessibility::XAccessibleContext,
74 : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
75 : ::com::sun::star::accessibility::XAccessibleSelection,
76 : ::com::sun::star::lang::XServiceInfo,
77 : ::com::sun::star::lang::XServiceName >
78 : SvxGraphCtrlAccessibleContext_Base;
79 :
80 : class SvxGraphCtrlAccessibleContext : public SvxGraphCtrlAccessibleContext_Base, ::comphelper::OBaseMutex, SfxListener, ::accessibility::IAccessibleViewForwarder
81 : {
82 : public:
83 : friend class GraphCtrl;
84 :
85 : //===== internal ========================================================
86 : SvxGraphCtrlAccessibleContext(
87 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
88 : GraphCtrl& rRepresentation,
89 : const OUString* pName = NULL,
90 : const OUString* pDescription = NULL );
91 :
92 : void Notify( SfxBroadcaster& aBC, const SfxHint& aHint ) SAL_OVERRIDE;
93 :
94 : protected:
95 : virtual ~SvxGraphCtrlAccessibleContext();
96 : public:
97 : //===== XAccessible =====================================================
98 :
99 : /// Return the XAccessibleContext.
100 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
101 : getAccessibleContext (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 :
103 : //===== XAccessibleComponent ============================================
104 :
105 : virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 : 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, std::exception) SAL_OVERRIDE;
107 : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 : virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 : virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 : virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
112 : virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
113 : virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() throw (::com::sun::star::uno::RuntimeException);
115 :
116 : virtual sal_Int32 SAL_CALL getForeground (void)
117 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 :
119 : virtual sal_Int32 SAL_CALL getBackground (void)
120 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 :
122 :
123 : //===== XAccessibleContext ==============================================
124 :
125 : virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : 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, std::exception) SAL_OVERRIDE;
127 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 : virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 : virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 : virtual OUString SAL_CALL getAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : virtual OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
133 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 : virtual ::com::sun::star::lang::Locale SAL_CALL getLocale (void) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException, std::exception) SAL_OVERRIDE;
135 : // virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
136 : // virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
137 :
138 : //===== XAccessibleEventBroadcaster =====================================
139 :
140 : virtual void SAL_CALL addAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual void SAL_CALL removeAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 :
143 : //===== XServiceInfo ====================================================
144 :
145 : virtual OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : virtual sal_Bool SAL_CALL supportsService (const OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 : virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 :
149 : //===== XTypeProvider ===================================================
150 :
151 : virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 :
153 : //===== XServiceName ====================================================
154 :
155 : virtual OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 :
157 : //===== XAccessibleSelection =============================================
158 :
159 : virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
160 : virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
161 : virtual void SAL_CALL clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
162 : virtual void SAL_CALL selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
163 : virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
164 : 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, std::exception ) SAL_OVERRIDE;
165 : virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
166 :
167 : //===== IAccessibleViewforwarder ========================================
168 :
169 : virtual bool IsValid (void) const SAL_OVERRIDE;
170 : virtual Rectangle GetVisibleArea() const SAL_OVERRIDE;
171 : virtual Point LogicToPixel (const Point& rPoint) const SAL_OVERRIDE;
172 : virtual Size LogicToPixel (const Size& rSize) const SAL_OVERRIDE;
173 : virtual Point PixelToLogic (const Point& rPoint) const SAL_OVERRIDE;
174 : virtual Size PixelToLogic (const Size& rSize) const SAL_OVERRIDE;
175 :
176 : protected:
177 : //===== internals ========================================================
178 :
179 : void checkChildIndexOnSelection( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
180 :
181 : public:
182 :
183 : /** This method is used by the graph control to tell the
184 : accessibility object about a new model and view.
185 : */
186 : void setModelAndView (SdrModel* pModel, SdrView* pView);
187 :
188 : protected:
189 :
190 : /** Return the object's current bounding box relative to the desktop,
191 : i.e in absolute pixel coordinates.
192 : @return
193 : The returned rectangle is a bounding box of the object given in
194 : absolute screen coordinates.
195 : @raise DisposedException
196 : When the object is already disposed then a
197 : <type>DisposedException</type> is thrown.
198 : */
199 : virtual Rectangle GetBoundingBoxOnScreen(void) throw (::com::sun::star::uno::RuntimeException);
200 :
201 : /// Return the object's current bounding box relative to the parent object.
202 : virtual Rectangle GetBoundingBox(void) throw (::com::sun::star::uno::RuntimeException);
203 :
204 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
205 :
206 : private:
207 : SdrObject* getSdrObject( sal_Int32 nIndex )
208 : throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
209 :
210 : void CommitChange (sal_Int16 aEventId, const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue);
211 : void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject& aEvent);
212 :
213 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessible( const SdrObject* pObj );
214 :
215 : accessibility::AccessibleShapeTreeInfo maTreeInfo;
216 :
217 : /// Reference to the parent object.
218 : ::com::sun::star::uno::Reference<
219 : ::com::sun::star::accessibility::XAccessible> mxParent;
220 :
221 : /** Description of this object. This is not a constant because it can
222 : be set from the outside.
223 : */
224 : OUString msDescription;
225 :
226 : /** Name of this object.
227 : */
228 : OUString msName;
229 :
230 : /// map of accessible shapes
231 : struct SdrObjectCompareLess
232 : {
233 0 : bool operator()(const SdrObject* p1, const SdrObject* p2) const
234 : {
235 0 : return p1 < p2;
236 : }
237 : };
238 : typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType;
239 : ShapesMapType mxShapes;
240 :
241 : GraphCtrl* mpControl;
242 :
243 : SdrModel* mpModel;
244 : SdrPage* mpPage;
245 : SdrView* mpView;
246 :
247 : /// client id in the AccessibleEventNotifier queue
248 : sal_uInt32 mnClientId;
249 :
250 : sal_Bool mbDisposed;
251 : };
252 :
253 : #endif
254 :
255 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|