xref: /trunk/main/svtools/inc/svtools/accessibleruler.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 #ifndef _SVTRULERACCESSIBLE_HXX
23 #define _SVTRULERACCESSIBLE_HXX
24 
25 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
26 #include <com/sun/star/accessibility/XAccessible.hpp>
27 #endif
28 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECOMPONENT_HPP_
29 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
30 #endif
31 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECONTEXT_HPP_
32 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
33 #endif
34 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEEVENTBROADCASTER_HPP_
35 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ILLEGALACCESSIBLECOMPONENTSTATEEXCEPTION_HPP_
38 #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
39 #endif
40 
41 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
42 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
45 #include <com/sun/star/uno/Reference.hxx>
46 #endif
47 #ifndef _CPPUHELPER_WEAK_HXX_
48 #include <cppuhelper/weak.hxx>
49 #endif
50 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #endif
53 #ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
54 #include <com/sun/star/lang/XTypeProvider.hpp>
55 #endif
56 #ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
57 #include <com/sun/star/lang/XServiceName.hpp>
58 #endif
59 #ifndef _COM_SUN_STAR_LANG_INDEXOUTOFBOUNDSEXCEPTION_HPP_
60 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
61 #endif
62 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
63 #include <com/sun/star/lang/DisposedException.hpp>
64 #endif
65 #ifndef _VOS_MUTEX_HXX_
66 #include <vos/mutex.hxx>
67 #endif
68 #ifndef _CPPUHELPER_INTERFACECONTAINER_H_
69 #include <cppuhelper/interfacecontainer.h>
70 #endif
71 #ifndef _CPPUHELPER_COMPBASE5_HXX_
72 #include <cppuhelper/compbase5.hxx>
73 #endif
74 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
75 #include <comphelper/broadcasthelper.hxx>
76 #endif
77 #ifndef _CPPUHELPER_IMPLBASE5_HXX_
78 #include <cppuhelper/implbase5.hxx>
79 #endif
80 #ifndef _UTL_SERVICEHELPER_HXX_
81 #include <comphelper/servicehelper.hxx>
82 #endif
83 
84 namespace com { namespace sun { namespace star { namespace awt {
85     struct Point;
86     struct Rectangle;
87     struct Size;
88     class XFocusListener;
89 } } } }
90 
91 class Rectangle;
92 class Ruler;
93 class Window;
94 
95 
96 typedef ::cppu::WeakAggComponentImplHelper5<
97             ::com::sun::star::accessibility::XAccessible,
98             ::com::sun::star::accessibility::XAccessibleComponent,
99             ::com::sun::star::accessibility::XAccessibleContext,
100             ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
101             ::com::sun::star::lang::XServiceInfo >
102             SvtRulerAccessible_Base;
103 
104 class SvtRulerAccessible : public ::comphelper::OBaseMutex, public SvtRulerAccessible_Base
105 {
106 public:
107     //=====  internal  ========================================================
108     SvtRulerAccessible(
109         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, Ruler& rRepresentation, const ::rtl::OUString& rName );
110 protected:
111     virtual ~SvtRulerAccessible();
112 public:
113     //=====  XAccessible  =====================================================
114 
115     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
116         getAccessibleContext( void );
117 
118     //=====  XAccessibleComponent  ============================================
119 
120     virtual sal_Bool SAL_CALL
121         containsPoint( const ::com::sun::star::awt::Point& rPoint );
122 
123     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
124         getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint );
125 
126     virtual ::com::sun::star::awt::Rectangle SAL_CALL
127         getBounds();
128 
129     virtual ::com::sun::star::awt::Point SAL_CALL
130         getLocation();
131 
132     virtual ::com::sun::star::awt::Point SAL_CALL
133         getLocationOnScreen();
134 
135     virtual ::com::sun::star::awt::Size SAL_CALL
136         getSize();
137 
138     virtual sal_Bool SAL_CALL
139         isShowing();
140 
141     virtual sal_Bool SAL_CALL
142         isVisible();
143 
144     virtual sal_Bool SAL_CALL
145         isFocusTraversable();
146 
147     virtual void SAL_CALL
148         addFocusListener(
149             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener );
150 
151     virtual void SAL_CALL
152         removeFocusListener(
153             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener );
154 
155     virtual void SAL_CALL
156         grabFocus();
157 
158     virtual ::com::sun::star::uno::Any SAL_CALL
159         getAccessibleKeyBinding();
160     virtual sal_Int32 SAL_CALL
161         getForeground(  );
162     virtual sal_Int32 SAL_CALL
163         getBackground(  );
164 
165     //=====  XAccessibleContext  ==============================================
166 
167     virtual sal_Int32 SAL_CALL
168         getAccessibleChildCount( void );
169 
170     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
171         getAccessibleChild( sal_Int32 nIndex );
172 
173     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
174         getAccessibleParent( void );
175 
176     virtual sal_Int32 SAL_CALL
177         getAccessibleIndexInParent( void );
178 
179     virtual sal_Int16 SAL_CALL
180         getAccessibleRole( void );
181 
182     virtual ::rtl::OUString SAL_CALL
183         getAccessibleDescription( void );
184 
185     virtual ::rtl::OUString SAL_CALL
186         getAccessibleName( void );
187 
188     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL
189         getAccessibleRelationSet( void );
190 
191     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
192         getAccessibleStateSet( void );
193 
194     virtual ::com::sun::star::lang::Locale SAL_CALL
195         getLocale( void );
196     //=====  XAccessibleEventBroadcaster  =====================================
197 
198     virtual void SAL_CALL
199         addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener );
200 
201     virtual void SAL_CALL
202         removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener );
203 
204     // Needed, because some compilers would complain about virtual functions above would hide cppu::WeakAggComponentImplHelperBase::add/removeEventListener(const Reference<lang::XEventListener>&)...
205     virtual void SAL_CALL
206         addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener );
207 
208     virtual void SAL_CALL
209         removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener );
210 
211 
212     //=====  XServiceInfo  ====================================================
213 
214     virtual ::rtl::OUString SAL_CALL
215         getImplementationName( void );
216 
217     virtual sal_Bool SAL_CALL
218         supportsService( const ::rtl::OUString& sServiceName );
219 
220     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
221         getSupportedServiceNames( void );
222 
223     //=====  XTypeProvider  ===================================================
224 
225     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
226         getImplementationId( void );
227 
228 
229 
230 
231 public:
232 
233     /// Sets the name
234     void setName( const ::rtl::OUString& rName );
235 
236     /// Sets the description
237     void setDescription( const ::rtl::OUString& rDescr );
238 private:
239     static ::com::sun::star::uno::Sequence< sal_Int8 > getUniqueId( void );
240 protected:
241 
242     /// @Return the object's current bounding box relative to the desktop.
243     virtual Rectangle GetBoundingBoxOnScreen( void );
244 
245     /// @Return the object's current bounding box relative to the parent object.
246     virtual Rectangle GetBoundingBox( void );
247 
248 
249     virtual void SAL_CALL disposing();
250 
251     /// @returns true if it's disposed or in disposing
252     inline sal_Bool IsAlive( void ) const;
253 
254     /// @returns true if it's not disposed and no in disposing
255     inline sal_Bool IsNotAlive( void ) const;
256 
257     /// throws the exception DisposedException if it's not alive
258     void ThrowExceptionIfNotAlive( void );
259 
260 private:
261     /** Description of this object.  This is not a constant because it can
262         be set from the outside.
263     */
264     ::rtl::OUString                     msDescription;
265 
266     /** Name of this object.
267     */
268     ::rtl::OUString                     msName;
269 
270     /// Reference to the parent object.
271     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
272                                         mxParent;
273 
274     /// pointer to internal representation
275     Ruler*                          mpRepr;
276 
277         /// client id in the AccessibleEventNotifier queue
278     sal_uInt32 mnClientId;
279 
280 
281 };
282 
IsAlive(void) const283 inline sal_Bool SvtRulerAccessible::IsAlive( void ) const
284 {
285     return !rBHelper.bDisposed && !rBHelper.bInDispose;
286 }
287 
IsNotAlive(void) const288 inline sal_Bool SvtRulerAccessible::IsNotAlive( void ) const
289 {
290     return rBHelper.bDisposed || rBHelper.bInDispose;
291 }
292 
293 
294 
295 #endif
296