xref: /trunk/main/sd/source/ui/inc/AccessibleSlideSorterView.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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_SORTER_VIEW_HXX
25 #define SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_SORTER_VIEW_HXX
26 
27 #include "MutexOwner.hxx"
28 #include <cppuhelper/compbase6.hxx>
29 #include <com/sun/star/accessibility/XAccessible.hpp>
30 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
31 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
32 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
33 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/awt/XFocusListener.hpp>
37 #include <com/sun/star/document/XEventListener.hpp>
38 
39 
40 #include <memory>
41 
42 class Window;
43 
44 namespace sd { namespace slidesorter {
45 class SlideSorter;
46 } }
47 
48 namespace accessibility {
49 
50 
51 class AccessibleSlideSorterObject;
52 
53 typedef ::cppu::WeakComponentImplHelper6<
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::accessibility::XAccessibleSelection,
59     ::com::sun::star::lang::XServiceInfo
60     > AccessibleSlideSorterViewBase;
61 
62 /** This class makes the SlideSorterViewShell accessible.  It uses objects
63     of the AccessibleSlideSorterObject class to the make the page objects
64     accessible.
65 */
66 class AccessibleSlideSorterView
67     : public ::sd::MutexOwner,
68       public AccessibleSlideSorterViewBase
69 {
70 public:
71     AccessibleSlideSorterView(
72         ::sd::slidesorter::SlideSorter& rSlideSorter,
73         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> & rxParent,
74         ::Window* pParentWindow);
75 
76     virtual ~AccessibleSlideSorterView (void);
77 
78     /** This method acts like a dispose call.  It sends a disposing to all
79         of its listeners.  It may be called twice.
80     */
81     void Destroyed (void);
82 
83     void FireAccessibleEvent (
84         short nEventId,
85         const ::com::sun::star::uno::Any& rOldValue,
86         const ::com::sun::star::uno::Any& rNewValue);
87 
88     virtual void SAL_CALL disposing (void);
89 
90     /** Return the implementation object of the specified child.
91         @param nIndex
92             Index of the child for which to return the implementation object.
93     */
94     AccessibleSlideSorterObject* GetAccessibleChildImplementation (sal_Int32 nIndex);
95 
96     //===== XAccessible =======================================================
97 
98     virtual ::com::sun::star::uno::Reference<
99         ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
100         getAccessibleContext (void);
101 
102 
103     //===== XAccessibleEventBroadcaster =======================================
104     virtual void SAL_CALL
105         addEventListener(
106             const ::com::sun::star::uno::Reference<
107             ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener);
108 
109     virtual void SAL_CALL
110         removeEventListener(
111             const ::com::sun::star::uno::Reference<
112             ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener );
113 
114     using cppu::WeakComponentImplHelperBase::addEventListener;
115     using cppu::WeakComponentImplHelperBase::removeEventListener;
116 
117     //=====  XAccessibleContext  ==============================================
118 
119     /// Return the number of currently visible children.
120     virtual sal_Int32 SAL_CALL
121         getAccessibleChildCount (void);
122 
123     /// Return the specified child or throw exception.
124     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
125         getAccessibleChild (sal_Int32 nIndex);
126 
127     /// Return a reference to the parent.
128     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
129         getAccessibleParent (void);
130 
131     /// Return this objects index among the parents children.
132     virtual sal_Int32 SAL_CALL
133         getAccessibleIndexInParent (void);
134 
135     /// Return this object's role.
136     virtual sal_Int16 SAL_CALL
137         getAccessibleRole (void);
138 
139     /// Return this object's description.
140     virtual ::rtl::OUString SAL_CALL
141         getAccessibleDescription (void);
142 
143     /// Return the object's current name.
144     virtual ::rtl::OUString SAL_CALL
145         getAccessibleName (void);
146 
147     /// Return NULL to indicate that an empty relation set.
148     virtual ::com::sun::star::uno::Reference<
149             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
150         getAccessibleRelationSet (void);
151 
152     /// Return the set of current states.
153     virtual ::com::sun::star::uno::Reference<
154             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
155         getAccessibleStateSet (void);
156 
157     /** Return the parents locale or throw exception if this object has no
158         parent yet/anymore.
159     */
160     virtual ::com::sun::star::lang::Locale SAL_CALL
161         getLocale (void);
162 
163     //=====  XAccessibleComponent  ================================================
164 
165     /** The default implementation uses the result of
166         <member>getBounds</member> to determine whether the given point lies
167         inside this object.
168     */
169     virtual sal_Bool SAL_CALL containsPoint (
170         const ::com::sun::star::awt::Point& aPoint);
171 
172     /** The default implementation returns an empty reference.
173     */
174     virtual ::com::sun::star::uno::Reference<
175         ::com::sun::star::accessibility::XAccessible > SAL_CALL
176         getAccessibleAtPoint (
177             const ::com::sun::star::awt::Point& aPoint);
178 
179     /** The default implementation returns an empty rectangle.
180     */
181     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void);
182 
183     /** The default implementation uses the result of
184         <member>getBounds</member> to determine the location.
185     */
186     virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void);
187 
188     /** The default implementation returns an empty position, i.e. the
189     * result of the default constructor of <type>com::sun::star::awt::Point</type>.
190     */
191     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void);
192 
193     /** The default implementation uses the result of
194         <member>getBounds</member> to determine the size.
195     */
196     virtual ::com::sun::star::awt::Size SAL_CALL getSize (void);
197 
198     /** The default implementation does nothing.
199     */
200     virtual void SAL_CALL grabFocus (void);
201 
202     /** Returns black as the default foreground color.
203     */
204     virtual sal_Int32 SAL_CALL getForeground (void);
205 
206     /** Returns white as the default background color.
207     */
208     virtual sal_Int32 SAL_CALL getBackground (void);
209 
210 
211     //===== XAccessibleSelection ==============================================
212 
213     virtual void SAL_CALL
214         selectAccessibleChild (sal_Int32 nChildIndex);
215 
216     virtual sal_Bool SAL_CALL
217         isAccessibleChildSelected( sal_Int32 nChildIndex );
218 
219     virtual void SAL_CALL
220         clearAccessibleSelection(  );
221 
222     virtual void SAL_CALL
223         selectAllAccessibleChildren(  );
224 
225     virtual sal_Int32 SAL_CALL
226         getSelectedAccessibleChildCount(  );
227 
228     virtual ::com::sun::star::uno::Reference<
229         ::com::sun::star::accessibility::XAccessible > SAL_CALL
230         getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex );
231 
232     virtual void SAL_CALL
233         deselectAccessibleChild( sal_Int32 nSelectedChildIndex );
234 
235 
236     //=====  XServiceInfo  ====================================================
237 
238     /** Returns an identifier for the implementation of this object.
239     */
240     virtual ::rtl::OUString SAL_CALL
241         getImplementationName (void);
242 
243     /** Return whether the specified service is supported by this class.
244     */
245     virtual sal_Bool SAL_CALL
246         supportsService (const ::rtl::OUString& sServiceName);
247 
248     /** Returns a list of all supported services.
249     */
250     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
251         getSupportedServiceNames (void);
252 
253     virtual void SwitchViewActivated (void);
254 private:
255     class Implementation;
256     ::std::auto_ptr<Implementation> mpImpl;
257 
258     ::sd::slidesorter::SlideSorter& mrSlideSorter;
259 
260     ::com::sun::star::uno::Reference<
261         ::com::sun::star::accessibility::XAccessible> mxParent;
262 
263     sal_uInt32 mnClientId;
264 
265     ::Window* mpContentWindow;
266 
267     /** Check whether or not the object has been disposed (or is in the
268         state of being disposed).  If that is the case then
269         DisposedException is thrown to inform the (indirect) caller of the
270         foul deed.
271     */
272     void ThrowIfDisposed (void);
273 
274     /** Check whether or not the object has been disposed (or is in the
275         state of being disposed).
276 
277         @return sal_True, if the object is disposed or in the course
278         of being disposed. Otherwise, sal_False is returned.
279     */
280     sal_Bool IsDisposed (void);
281 };
282 
283 } // end of namespace ::accessibility
284 
285 #endif
286