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_OBJECT_HXX
25 #define SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_SORTER_OBJECT_HXX
26 
27 #include "MutexOwner.hxx"
28 #include <cppuhelper/compbase5.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/awt/XFocusListener.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
37 
38 class SdPage;
39 
40 namespace sd { namespace slidesorter {
41 class SlideSorter;
42 } }
43 
44 namespace accessibility {
45 
46 
47 typedef ::cppu::WeakComponentImplHelper5<
48     ::com::sun::star::accessibility::XAccessible,
49     ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
50     ::com::sun::star::accessibility::XAccessibleContext,
51     ::com::sun::star::accessibility::XAccessibleComponent,
52     ::com::sun::star::lang::XServiceInfo > AccessibleSlideSorterObjectBase;
53 
54 
55 /** This class makes page objects of the slide sorter accessible.
56 */
57 class AccessibleSlideSorterObject
58     : public ::sd::MutexOwner,
59       public AccessibleSlideSorterObjectBase
60 {
61 public:
62     /** Create a new object that represents a page object in the slide
63         sorter.
64         @param rxParent
65             The accessible parent.
66         @param rSlideSorter
67             The slide sorter whose model manages the page.
68         @param nPageNumber
69             The number of the page in the range [0,nPageCount).
70     */
71     AccessibleSlideSorterObject(
72         const ::com::sun::star::uno::Reference<
73             ::com::sun::star::accessibility::XAccessible >& rxParent,
74         ::sd::slidesorter::SlideSorter& rSlideSorter,
75         sal_uInt16 nPageNumber);
76     ~AccessibleSlideSorterObject (void);
77 
78     /** Return the page that is made accessible by the called object.
79     */
80     SdPage* GetPage (void) const;
81 
82     /** The page number as given to the constructor.
83     */
84     sal_uInt16 GetPageNumber (void) const;
85 
86     void FireAccessibleEvent (
87         short nEventId,
88         const ::com::sun::star::uno::Any& rOldValue,
89         const ::com::sun::star::uno::Any& rNewValue);
90 
91     virtual void SAL_CALL disposing (void);
92 
93 
94 
95     //===== XAccessible =======================================================
96 
97     virtual ::com::sun::star::uno::Reference<
98         ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
99         getAccessibleContext (void)
100         throw (::com::sun::star::uno::RuntimeException);
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         throw (::com::sun::star::uno::RuntimeException);
109 
110     virtual void SAL_CALL
111         removeEventListener(
112             const ::com::sun::star::uno::Reference<
113             ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener )
114         throw (::com::sun::star::uno::RuntimeException);
115 
116 	using cppu::WeakComponentImplHelperBase::addEventListener;
117 	using cppu::WeakComponentImplHelperBase::removeEventListener;
118 
119 	//=====  XAccessibleContext  ==============================================
120 
121     virtual sal_Int32 SAL_CALL
122     	getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
123 
124     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
125     	getAccessibleChild (sal_Int32 nIndex)
126         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
127 
128 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
129     	getAccessibleParent (void)
130         throw (::com::sun::star::uno::RuntimeException);
131 
132 	virtual	sal_Int32 SAL_CALL
133     	getAccessibleIndexInParent (void)
134         throw (::com::sun::star::uno::RuntimeException);
135 
136 	virtual sal_Int16 SAL_CALL
137     	getAccessibleRole (void)
138         throw (::com::sun::star::uno::RuntimeException);
139 
140 	virtual ::rtl::OUString SAL_CALL
141     	getAccessibleDescription (void)
142         throw (::com::sun::star::uno::RuntimeException);
143 
144 	virtual ::rtl::OUString SAL_CALL
145     	getAccessibleName (void)
146         throw (::com::sun::star::uno::RuntimeException);
147 
148 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
149     	getAccessibleRelationSet (void)
150         throw (::com::sun::star::uno::RuntimeException);
151 
152     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
153         getAccessibleStateSet (void)
154         throw (::com::sun::star::uno::RuntimeException);
155 
156     virtual ::com::sun::star::lang::Locale SAL_CALL
157     	getLocale (void)
158 		throw (::com::sun::star::uno::RuntimeException,
159 			::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
160 
161 
162     //=====  XAccessibleComponent  ================================================
163 
164     virtual sal_Bool SAL_CALL containsPoint (
165         const ::com::sun::star::awt::Point& aPoint)
166         throw (::com::sun::star::uno::RuntimeException);
167 
168     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
169         getAccessibleAtPoint (
170             const ::com::sun::star::awt::Point& aPoint)
171         throw (::com::sun::star::uno::RuntimeException);
172 
173     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
174         throw (::com::sun::star::uno::RuntimeException);
175 
176     virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
177         throw (::com::sun::star::uno::RuntimeException);
178 
179     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
180         throw (::com::sun::star::uno::RuntimeException);
181 
182     virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
183         throw (::com::sun::star::uno::RuntimeException);
184 
185     virtual void SAL_CALL grabFocus (void)
186         throw (::com::sun::star::uno::RuntimeException);
187 
188     virtual sal_Int32 SAL_CALL getForeground (void)
189         throw (::com::sun::star::uno::RuntimeException);
190 
191     virtual sal_Int32 SAL_CALL getBackground (void)
192         throw (::com::sun::star::uno::RuntimeException);
193 
194 
195 
196 	//=====  XServiceInfo  ====================================================
197 
198     /**	Returns an identifier for the implementation of this object.
199     */
200 	virtual ::rtl::OUString SAL_CALL
201     	getImplementationName (void)
202         throw (::com::sun::star::uno::RuntimeException);
203 
204     /**	Return whether the specified service is supported by this class.
205     */
206     virtual sal_Bool SAL_CALL
207     	supportsService (const ::rtl::OUString& sServiceName)
208         throw (::com::sun::star::uno::RuntimeException);
209 
210     /** Returns a list of all supported services.
211     */
212     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
213     	getSupportedServiceNames (void)
214         throw (::com::sun::star::uno::RuntimeException);
215 
216 
217 private:
218     ::com::sun::star::uno::Reference<
219         ::com::sun::star::accessibility::XAccessible> mxParent;
220     sal_uInt16 mnPageNumber;
221     ::sd::slidesorter::SlideSorter& mrSlideSorter;
222     sal_uInt32 mnClientId;
223 
224     /** Check whether or not the object has been disposed (or is in the
225         state of beeing disposed).  If that is the case then
226         DisposedException is thrown to inform the (indirect) caller of the
227         foul deed.
228     */
229     void ThrowIfDisposed (void)
230         throw (::com::sun::star::lang::DisposedException);
231 
232     /** Check whether or not the object has been disposed (or is in the
233         state of beeing disposed).
234 
235         @return sal_True, if the object is disposed or in the course
236         of being disposed. Otherwise, sal_False is returned.
237     */
238     sal_Bool IsDisposed (void);
239 };
240 
241 
242 
243 } // end of namespace ::accessibility
244 
245 #endif
246