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_VIEW_HXX
29 #define SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_VIEW_HXX
30 
31 #include <cppuhelper/implbase6.hxx>
32 #include <cppuhelper/implbase7.hxx>
33 #include "SlideView.hxx"
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/accessibility/XAccessible.hpp>
36 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
37 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
38 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
39 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 
42 #include <vector>
43 
44 class SdDrawDocument;
45 class AccessibleSlideView;
46 
47 namespace sd {
48 class SlideView;
49 class Window;
50 }
51 
52 // -----------------------------
53 // - AccessibleSlideViewObject -
54 // -----------------------------
55 
56 class AccessibleSlideViewObject : public ::cppu::WeakImplHelper6<
57     ::com::sun::star::lang::XUnoTunnel,
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::lang::XServiceInfo >
63 {
64 private:
65 
66     ::osl::Mutex                                                                                                            maMutex;
67     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >                                mxParent;
68     AccessibleSlideView*                                                                                                    mpManager;
69     /// client id in the AccessibleEventNotifier queue
70     sal_uInt32                                                                                                              mnClientId;
71 	sal_uInt16		                                                                                                        mnPage;
72 	sal_Bool		                                                                                                        mbVisible;
73     sal_Bool                                                                                                                mbValid;
74 
75 private:
76 
77 	// Misc
78     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
79 
80     // XUnoTunnel
81     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
82 
83     // XAccessible
84     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
85 
86     // XAccessibleEventBroadcaster
87     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
88     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
89 
90     // XAccessibleContext
91     virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
92     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
93     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
94     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
95     virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
96     virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
97     virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
98     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
99     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
100     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
101 
102     // XAccessibleComponent
103     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
104     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
105     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
107     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
108     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
109     virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
110 
111     virtual sal_Int32 SAL_CALL getForeground (void)
112         throw (::com::sun::star::uno::RuntimeException);
113 
114     virtual sal_Int32 SAL_CALL getBackground (void)
115         throw (::com::sun::star::uno::RuntimeException);
116 
117 	//=====  XServiceInfo  ====================================================
118 
119     /**	Returns an identifier for the implementation of this object.
120     */
121 	virtual ::rtl::OUString SAL_CALL
122     	getImplementationName (void)
123         throw (::com::sun::star::uno::RuntimeException);
124 
125     /**	Return whether the specified service is supported by this class.
126     */
127     virtual sal_Bool SAL_CALL
128     	supportsService (const ::rtl::OUString& sServiceName)
129         throw (::com::sun::star::uno::RuntimeException);
130 
131     /** Returns a list of all supported services.
132     */
133 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
134     	getSupportedServiceNames (void)
135         throw (::com::sun::star::uno::RuntimeException);
136 
137 public:
138 
139     static AccessibleSlideViewObject* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
140 
141 public:
142 
143 					            AccessibleSlideViewObject( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxParent, sal_uInt16 nPage, sal_Bool bVisible );
144 					            ~AccessibleSlideViewObject();
145 
146     void                        FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
147 
148     /** This method acts like a dispose call.  It sends a disposing to all
149         of its listeners.  It may be called twice.
150     */
151     void Destroyed (void);
152 
153     sal_uInt16                  GetPageNum() const { return mnPage; }
154 
155     void			            SetVisible( sal_Bool bVisible );
156 	sal_Bool		            IsVisible() const;
157 };
158 
159 // -----------------------
160 // - AccessibleSlideView -
161 // -----------------------
162 
163 class AccessibleSlideView : public ::cppu::WeakImplHelper7<
164     ::com::sun::star::lang::XUnoTunnel,
165     ::com::sun::star::accessibility::XAccessible,
166     ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
167     ::com::sun::star::accessibility::XAccessibleContext,
168     ::com::sun::star::accessibility::XAccessibleComponent,
169     ::com::sun::star::accessibility::XAccessibleSelection,
170     ::com::sun::star::lang::XServiceInfo >
171 {
172 public:
173 
174     static AccessibleSlideView* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
175 
176     AccessibleSlideView(
177         SdDrawDocument& rDoc,
178         ::sd::SlideView& rView,
179         ::sd::Window& rParentWindow);
180     virtual ~AccessibleSlideView (void);
181 
182     void                        FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
183 
184     /** This method acts like a dispose call.  It sends a disposing to all
185         of its listeners.  It may be called twice.
186     */
187     void Destroyed (void);
188 
189     SdDrawDocument*             GetDrawDocument() const { return mpDoc; }
190     ::sd::SlideView* GetSlideView() const { return mpView; }
191     ::sd::Window* GetParentWindow() const { return mpParentWindow; }
192 
193 	void			            SetPageVisible( sal_uInt16 nPage, sal_Bool bVisible );
194 	void			            Reset();
195     void                        FocusHasChanged( sal_uInt16 nOldFocusPage, sal_uInt16 nNewFocusPage );
196 
197 
198 private:
199     ::osl::Mutex maMutex;
200 	::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > >               maSlidePageObjects;
201     SdDrawDocument* mpDoc;
202 	::sd::SlideView* mpView;
203     ::sd::Window* mpParentWindow;
204      /// client id in the AccessibleEventNotifier queue
205     sal_uInt32 mnClientId;
206 
207     // internal
208 	static const ::com::sun::star::uno::Sequence< sal_Int8 >&                                   getUnoTunnelId();
209     sal_Int32                                                                                   ImplGetVisibleChildCount() const;
210     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >    ImplGetVisibleChild( sal_Int32 nVisibleChild ) const;
211 
212     // XUnoTunnel
213     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
214 
215     // XAccessible
216     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
217 
218     // XAccessibleEventBroadcaster
219     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
220     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
221 
222     // XAccessibleContext
223     virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
224     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
225     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
226     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
227     virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
228     virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
229     virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
230     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
231     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
232     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
233 
234     // XAccessibleComponent
235     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
236     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
237     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
238     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
239     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
240     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
241     virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
242 
243     virtual sal_Int32 SAL_CALL getForeground (void)
244         throw (::com::sun::star::uno::RuntimeException);
245 
246     virtual sal_Int32 SAL_CALL getBackground (void)
247         throw (::com::sun::star::uno::RuntimeException);
248 
249     // XAccessibleSelection
250     virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
251     virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
252     virtual void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
253     virtual void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
254     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
255     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);
256     virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
257 
258 	//=====  XServiceInfo  ====================================================
259 
260     /**	Returns an identifier for the implementation of this object.
261     */
262 	virtual ::rtl::OUString SAL_CALL
263     	getImplementationName (void)
264         throw (::com::sun::star::uno::RuntimeException);
265 
266     /**	Return whether the specified service is supported by this class.
267     */
268     virtual sal_Bool SAL_CALL
269     	supportsService (const ::rtl::OUString& sServiceName)
270         throw (::com::sun::star::uno::RuntimeException);
271 
272     /** Returns a list of all supported services.
273     */
274 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
275     	getSupportedServiceNames (void)
276         throw (::com::sun::star::uno::RuntimeException);
277 
278 };
279 
280 #endif
281