1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_SORTER_VIEW_HXX
29 #define SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_SORTER_VIEW_HXX
30 
31 #include "MutexOwner.hxx"
32 #include <cppuhelper/compbase6.hxx>
33 #include <com/sun/star/accessibility/XAccessible.hpp>
34 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
35 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
36 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
37 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/lang/DisposedException.hpp>
40 #include <com/sun/star/awt/XFocusListener.hpp>
41 #include <com/sun/star/document/XEventListener.hpp>
42 
43 
44 #include <memory>
45 
46 class Window;
47 
48 namespace sd { namespace slidesorter {
49 class SlideSorter;
50 } }
51 
52 namespace accessibility {
53 
54 
55 class AccessibleSlideSorterObject;
56 
57 typedef ::cppu::WeakComponentImplHelper6<
58     ::com::sun::star::accessibility::XAccessible,
59     ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
60     ::com::sun::star::accessibility::XAccessibleContext,
61     ::com::sun::star::accessibility::XAccessibleComponent,
62     ::com::sun::star::accessibility::XAccessibleSelection,
63     ::com::sun::star::lang::XServiceInfo
64     > AccessibleSlideSorterViewBase;
65 
66 /** This class makes the SlideSorterViewShell accessible.  It uses objects
67     of the AccessibleSlideSorterObject class to the make the page objects
68     accessible.
69 */
70 class AccessibleSlideSorterView
71     : public ::sd::MutexOwner,
72       public AccessibleSlideSorterViewBase
73 {
74 public:
75     AccessibleSlideSorterView(
76         ::sd::slidesorter::SlideSorter& rSlideSorter,
77 	    const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> & rxParent,
78         ::Window* pParentWindow);
79 
80     virtual ~AccessibleSlideSorterView (void);
81 
82     /** This method acts like a dispose call.  It sends a disposing to all
83         of its listeners.  It may be called twice.
84     */
85     void Destroyed (void);
86 
87     void FireAccessibleEvent (
88         short nEventId,
89         const ::com::sun::star::uno::Any& rOldValue,
90         const ::com::sun::star::uno::Any& rNewValue);
91 
92     virtual void SAL_CALL disposing (void);
93 
94     /** Return the implementation object of the specified child.
95         @param nIndex
96             Index of the child for which to return the implementation object.
97     */
98     AccessibleSlideSorterObject* GetAccessibleChildImplementation (sal_Int32 nIndex);
99 
100     //===== XAccessible =======================================================
101 
102     virtual ::com::sun::star::uno::Reference<
103         ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
104         getAccessibleContext (void)
105         throw (::com::sun::star::uno::RuntimeException);
106 
107 
108     //===== XAccessibleEventBroadcaster =======================================
109     virtual void SAL_CALL
110         addEventListener(
111             const ::com::sun::star::uno::Reference<
112             ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener)
113         throw (::com::sun::star::uno::RuntimeException);
114 
115     virtual void SAL_CALL
116         removeEventListener(
117             const ::com::sun::star::uno::Reference<
118             ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener )
119         throw (::com::sun::star::uno::RuntimeException);
120 
121 	using cppu::WeakComponentImplHelperBase::addEventListener;
122 	using cppu::WeakComponentImplHelperBase::removeEventListener;
123 
124 	//=====  XAccessibleContext  ==============================================
125 
126     ///	Return the number of currently visible children.
127     virtual sal_Int32 SAL_CALL
128     	getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
129 
130     ///	Return the specified child or throw exception.
131     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
132     	getAccessibleChild (sal_Int32 nIndex)
133         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
134 
135     ///	Return a reference to the parent.
136 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
137     	getAccessibleParent (void)
138         throw (::com::sun::star::uno::RuntimeException);
139 
140     ///	Return this objects index among the parents children.
141 	virtual	sal_Int32 SAL_CALL
142     	getAccessibleIndexInParent (void)
143         throw (::com::sun::star::uno::RuntimeException);
144 
145     ///	Return this object's role.
146 	virtual sal_Int16 SAL_CALL
147     	getAccessibleRole (void)
148         throw (::com::sun::star::uno::RuntimeException);
149 
150     ///	Return this object's description.
151 	virtual ::rtl::OUString SAL_CALL
152     	getAccessibleDescription (void)
153         throw (::com::sun::star::uno::RuntimeException);
154 
155     ///	Return the object's current name.
156 	virtual ::rtl::OUString SAL_CALL
157     	getAccessibleName (void)
158         throw (::com::sun::star::uno::RuntimeException);
159 
160 	///	Return NULL to indicate that an empty relation set.
161 	virtual ::com::sun::star::uno::Reference<
162             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
163     	getAccessibleRelationSet (void)
164         throw (::com::sun::star::uno::RuntimeException);
165 
166     ///	Return the set of current states.
167 	virtual ::com::sun::star::uno::Reference<
168             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
169     	getAccessibleStateSet (void)
170         throw (::com::sun::star::uno::RuntimeException);
171 
172 	/**	Return the parents locale or throw exception if this object has no
173     	parent yet/anymore.
174     */
175 	virtual ::com::sun::star::lang::Locale SAL_CALL
176     	getLocale (void)
177 		throw (::com::sun::star::uno::RuntimeException,
178 			::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
179 
180     //=====  XAccessibleComponent  ================================================
181 
182     /** The default implementation uses the result of
183         <member>getBounds</member> to determine whether the given point lies
184         inside this object.
185     */
186     virtual sal_Bool SAL_CALL containsPoint (
187         const ::com::sun::star::awt::Point& aPoint)
188         throw (::com::sun::star::uno::RuntimeException);
189 
190     /** The default implementation returns an empty reference.
191     */
192     virtual ::com::sun::star::uno::Reference<
193         ::com::sun::star::accessibility::XAccessible > SAL_CALL
194         getAccessibleAtPoint (
195             const ::com::sun::star::awt::Point& aPoint)
196         throw (::com::sun::star::uno::RuntimeException);
197 
198     /** The default implementation returns an empty rectangle.
199     */
200     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
201         throw (::com::sun::star::uno::RuntimeException);
202 
203     /** The default implementation uses the result of
204         <member>getBounds</member> to determine the location.
205     */
206     virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
207         throw (::com::sun::star::uno::RuntimeException);
208 
209     /** The default implementation returns an empty position, i.e. the
210     * result of the default constructor of <type>com::sun::star::awt::Point</type>.
211     */
212     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
213         throw (::com::sun::star::uno::RuntimeException);
214 
215     /** The default implementation uses the result of
216         <member>getBounds</member> to determine the size.
217     */
218     virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
219         throw (::com::sun::star::uno::RuntimeException);
220 
221     /** The default implementation does nothing.
222     */
223     virtual void SAL_CALL grabFocus (void)
224         throw (::com::sun::star::uno::RuntimeException);
225 
226     /** Returns black as the default foreground color.
227     */
228     virtual sal_Int32 SAL_CALL getForeground (void)
229         throw (::com::sun::star::uno::RuntimeException);
230 
231     /** Returns white as the default background color.
232     */
233     virtual sal_Int32 SAL_CALL getBackground (void)
234         throw (::com::sun::star::uno::RuntimeException);
235 
236 
237     //===== XAccessibleSelection ==============================================
238 
239     virtual void SAL_CALL
240         selectAccessibleChild (sal_Int32 nChildIndex)
241         throw (::com::sun::star::lang::IndexOutOfBoundsException,
242             ::com::sun::star::uno::RuntimeException);
243 
244     virtual sal_Bool SAL_CALL
245         isAccessibleChildSelected( sal_Int32 nChildIndex )
246         throw (::com::sun::star::lang::IndexOutOfBoundsException,
247             ::com::sun::star::uno::RuntimeException);
248 
249     virtual void SAL_CALL
250         clearAccessibleSelection(  )
251         throw (::com::sun::star::uno::RuntimeException);
252 
253     virtual void SAL_CALL
254         selectAllAccessibleChildren(  )
255         throw (::com::sun::star::uno::RuntimeException);
256 
257     virtual sal_Int32 SAL_CALL
258         getSelectedAccessibleChildCount(  )
259         throw (::com::sun::star::uno::RuntimeException);
260 
261     virtual ::com::sun::star::uno::Reference<
262         ::com::sun::star::accessibility::XAccessible > SAL_CALL
263         getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
264         throw (::com::sun::star::lang::IndexOutOfBoundsException,
265             ::com::sun::star::uno::RuntimeException);
266 
267     virtual void SAL_CALL
268         deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
269         throw (::com::sun::star::lang::IndexOutOfBoundsException,
270             ::com::sun::star::uno::RuntimeException);
271 
272 
273 	//=====  XServiceInfo  ====================================================
274 
275     /**	Returns an identifier for the implementation of this object.
276     */
277 	virtual ::rtl::OUString SAL_CALL
278     	getImplementationName (void)
279         throw (::com::sun::star::uno::RuntimeException);
280 
281     /**	Return whether the specified service is supported by this class.
282     */
283     virtual sal_Bool SAL_CALL
284     	supportsService (const ::rtl::OUString& sServiceName)
285         throw (::com::sun::star::uno::RuntimeException);
286 
287     /** Returns a list of all supported services.
288     */
289 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
290     	getSupportedServiceNames (void)
291         throw (::com::sun::star::uno::RuntimeException);
292 
293 
294 private:
295     class Implementation;
296     ::std::auto_ptr<Implementation> mpImpl;
297 
298     ::sd::slidesorter::SlideSorter& mrSlideSorter;
299 
300     ::com::sun::star::uno::Reference<
301         ::com::sun::star::accessibility::XAccessible> mxParent;
302 
303     sal_uInt32 mnClientId;
304 
305     ::Window* mpContentWindow;
306 
307     /** Check whether or not the object has been disposed (or is in the
308         state of beeing disposed).  If that is the case then
309         DisposedException is thrown to inform the (indirect) caller of the
310         foul deed.
311     */
312     void ThrowIfDisposed (void)
313         throw (::com::sun::star::lang::DisposedException);
314 
315     /** Check whether or not the object has been disposed (or is in the
316         state of beeing disposed).
317 
318         @return sal_True, if the object is disposed or in the course
319         of being disposed. Otherwise, sal_False is returned.
320     */
321     sal_Bool IsDisposed (void);
322 };
323 
324 } // end of namespace ::accessibility
325 
326 #endif
327