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