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:
81 : comphelper::OBaseMutex, public SvxGraphCtrlAccessibleContext_Base,
82 : SfxListener, accessibility::IAccessibleViewForwarder
83 : {
84 : public:
85 : friend class GraphCtrl;
86 :
87 : // internal
88 : SvxGraphCtrlAccessibleContext(
89 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
90 : GraphCtrl& rRepresentation,
91 : const OUString* pName = NULL,
92 : const OUString* pDescription = NULL );
93 :
94 : void Notify( SfxBroadcaster& aBC, const SfxHint& aHint ) SAL_OVERRIDE;
95 :
96 : protected:
97 : virtual ~SvxGraphCtrlAccessibleContext();
98 : public:
99 : // XAccessible
100 : /// Return the XAccessibleContext.
101 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
102 : getAccessibleContext() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 :
104 : // XAccessibleComponent
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 grabFocus() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 :
113 : virtual sal_Int32 SAL_CALL getForeground()
114 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 :
116 : virtual sal_Int32 SAL_CALL getBackground()
117 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 :
119 : // XAccessibleContext
120 : virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : 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;
122 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleParent() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 : virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 : virtual sal_Int16 SAL_CALL getAccessibleRole() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 : virtual OUString SAL_CALL getAccessibleDescription() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual OUString SAL_CALL getAccessibleName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 : virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException, std::exception) SAL_OVERRIDE;
130 : // virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
131 : // virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
132 :
133 : // XAccessibleEventBroadcaster
134 : 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;
135 : 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;
136 :
137 : // XServiceInfo
138 : virtual OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 : virtual sal_Bool SAL_CALL supportsService (const OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 : virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 :
142 : // XTypeProvider
143 : virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 :
145 : // XServiceName
146 : virtual OUString SAL_CALL getServiceName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 :
148 : // XAccessibleSelection
149 : virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
150 : virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
151 : virtual void SAL_CALL clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
152 : virtual void SAL_CALL selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
153 : virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
154 : 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;
155 : virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
156 :
157 : // IAccessibleViewforwarder
158 : virtual bool IsValid() const SAL_OVERRIDE;
159 : virtual Rectangle GetVisibleArea() const SAL_OVERRIDE;
160 : virtual Point LogicToPixel (const Point& rPoint) const SAL_OVERRIDE;
161 : virtual Size LogicToPixel (const Size& rSize) const SAL_OVERRIDE;
162 : virtual Point PixelToLogic (const Point& rPoint) const SAL_OVERRIDE;
163 : virtual Size PixelToLogic (const Size& rSize) const SAL_OVERRIDE;
164 :
165 : protected:
166 : void checkChildIndexOnSelection( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
167 :
168 : public:
169 :
170 : /** This method is used by the graph control to tell the
171 : accessibility object about a new model and view.
172 : */
173 : void setModelAndView (SdrModel* pModel, SdrView* pView);
174 :
175 : protected:
176 :
177 : /** Return the object's current bounding box relative to the desktop,
178 : i.e in absolute pixel coordinates.
179 : @return
180 : The returned rectangle is a bounding box of the object given in
181 : absolute screen coordinates.
182 : @raise DisposedException
183 : When the object is already disposed then a
184 : <type>DisposedException</type> is thrown.
185 : */
186 : Rectangle GetBoundingBoxOnScreen() throw (::com::sun::star::uno::RuntimeException);
187 :
188 : /// Return the object's current bounding box relative to the parent object.
189 : Rectangle GetBoundingBox() throw (::com::sun::star::uno::RuntimeException);
190 :
191 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
192 :
193 : private:
194 : SdrObject* getSdrObject( sal_Int32 nIndex )
195 : throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
196 :
197 : void CommitChange (sal_Int16 aEventId, const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue);
198 : void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject& aEvent);
199 :
200 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessible( const SdrObject* pObj );
201 :
202 : accessibility::AccessibleShapeTreeInfo maTreeInfo;
203 :
204 : /// Reference to the parent object.
205 : ::com::sun::star::uno::Reference<
206 : ::com::sun::star::accessibility::XAccessible> mxParent;
207 :
208 : /** Description of this object. This is not a constant because it can
209 : be set from the outside.
210 : */
211 : OUString msDescription;
212 :
213 : /** Name of this object.
214 : */
215 : OUString msName;
216 :
217 : /// map of accessible shapes
218 : struct SdrObjectCompareLess
219 : {
220 0 : bool operator()(const SdrObject* p1, const SdrObject* p2) const
221 : {
222 0 : return p1 < p2;
223 : }
224 : };
225 : typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType;
226 : ShapesMapType mxShapes;
227 :
228 : VclPtr<GraphCtrl> mpControl;
229 :
230 : SdrModel* mpModel;
231 : SdrPage* mpPage;
232 : SdrView* mpView;
233 :
234 : /// client id in the AccessibleEventNotifier queue
235 : sal_uInt32 mnClientId;
236 :
237 : bool mbDisposed;
238 : };
239 :
240 : #endif
241 :
242 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|