Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
30 : : #define SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
31 : :
32 : : #include "MutexOwner.hxx"
33 : : #include <cppuhelper/compbase5.hxx>
34 : : #include <com/sun/star/accessibility/XAccessible.hpp>
35 : : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
36 : : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
37 : : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
38 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
39 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40 : : #include <com/sun/star/lang/XServiceInfo.hpp>
41 : : #include <com/sun/star/lang/DisposedException.hpp>
42 : : #include <com/sun/star/awt/XFocusListener.hpp>
43 : : #include <com/sun/star/document/XEventListener.hpp>
44 : : #include <unotools/accessiblestatesethelper.hxx>
45 : : #include <tools/link.hxx>
46 : : #include <rtl/ref.hxx>
47 : :
48 : : class VclWindowEvent;
49 : :
50 : : namespace sd { namespace toolpanel {
51 : : class TreeNode;
52 : : class TreeNodeStateChangeEvent;
53 : : } }
54 : :
55 : :
56 : : namespace utl {
57 : : class AccessibleStateSetHelper;
58 : : }
59 : :
60 : : namespace accessibility {
61 : :
62 : :
63 : : typedef ::cppu::PartialWeakComponentImplHelper5<
64 : : ::com::sun::star::accessibility::XAccessible,
65 : : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
66 : : ::com::sun::star::accessibility::XAccessibleContext,
67 : : ::com::sun::star::accessibility::XAccessibleComponent,
68 : : ::com::sun::star::lang::XServiceInfo
69 : : > AccessibleTreeNodeBase;
70 : :
71 : : /** This class makes objects based on the sd::toolpanel::TreeNode
72 : : accessible.
73 : : */
74 : : class AccessibleTreeNode
75 : : : public ::sd::MutexOwner,
76 : : public AccessibleTreeNodeBase
77 : : {
78 : : public:
79 : : /** Create a new object for the given tree node. The accessible parent
80 : : is taken from the window returned by GetAccessibleParent() when
81 : : called at the window of the node.
82 : : @param rNode
83 : : The TreeNode to make accessible.
84 : : @param rsName
85 : : The accessible name that will be returned by getAccessibleName().
86 : : @param rsDescription
87 : : The accessible description that will be returned by
88 : : getAccessibleDescription().
89 : : @param eRole
90 : : The role that will be returned by getAccessibleRole().
91 : : */
92 : : AccessibleTreeNode(
93 : : ::sd::toolpanel::TreeNode& rNode,
94 : : const ::rtl::OUString& rsName,
95 : : const ::rtl::OUString& rsDescription,
96 : : sal_Int16 eRole);
97 : :
98 : : void FireAccessibleEvent (
99 : : short nEventId,
100 : : const ::com::sun::star::uno::Any& rOldValue,
101 : : const ::com::sun::star::uno::Any& rNewValue);
102 : :
103 : : virtual void SAL_CALL disposing (void);
104 : :
105 : : //===== XComponent =======================================================
106 : :
107 : 0 : virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
108 : 0 : { WeakComponentImplHelperBase::dispose(); }
109 : 0 : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
110 : 0 : { WeakComponentImplHelperBase::addEventListener(xListener); }
111 : 0 : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
112 : 0 : { WeakComponentImplHelperBase::removeEventListener(xListener); }
113 : :
114 : : //===== XAccessible =======================================================
115 : :
116 : : virtual ::com::sun::star::uno::Reference<
117 : : ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
118 : : getAccessibleContext (void)
119 : : throw (::com::sun::star::uno::RuntimeException);
120 : :
121 : :
122 : : //===== XAccessibleEventBroadcaster =======================================
123 : :
124 : : virtual void SAL_CALL
125 : : addEventListener(
126 : : const ::com::sun::star::uno::Reference<
127 : : ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener)
128 : : throw (::com::sun::star::uno::RuntimeException);
129 : :
130 : : virtual void SAL_CALL
131 : : removeEventListener(
132 : : const ::com::sun::star::uno::Reference<
133 : : ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener )
134 : : throw (::com::sun::star::uno::RuntimeException);
135 : :
136 : : //===== XAccessibleContext ==============================================
137 : :
138 : : /// Return the number of currently visible children.
139 : : virtual sal_Int32 SAL_CALL
140 : : getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
141 : :
142 : : /// Return the specified child or throw exception.
143 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
144 : : getAccessibleChild (sal_Int32 nIndex)
145 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
146 : :
147 : : /// Return a reference to the parent.
148 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
149 : : getAccessibleParent (void)
150 : : throw (::com::sun::star::uno::RuntimeException);
151 : :
152 : : /// Return this objects index among the parents children.
153 : : virtual sal_Int32 SAL_CALL
154 : : getAccessibleIndexInParent (void)
155 : : throw (::com::sun::star::uno::RuntimeException);
156 : :
157 : : /// Return this object's role.
158 : : virtual sal_Int16 SAL_CALL
159 : : getAccessibleRole (void)
160 : : throw (::com::sun::star::uno::RuntimeException);
161 : :
162 : : /// Return this object's description.
163 : : virtual ::rtl::OUString SAL_CALL
164 : : getAccessibleDescription (void)
165 : : throw (::com::sun::star::uno::RuntimeException);
166 : :
167 : : /// Return the object's current name.
168 : : virtual ::rtl::OUString SAL_CALL
169 : : getAccessibleName (void)
170 : : throw (::com::sun::star::uno::RuntimeException);
171 : :
172 : : /// Return NULL to indicate that an empty relation set.
173 : : virtual ::com::sun::star::uno::Reference<
174 : : ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
175 : : getAccessibleRelationSet (void)
176 : : throw (::com::sun::star::uno::RuntimeException);
177 : :
178 : : /// Return the set of current states.
179 : : virtual ::com::sun::star::uno::Reference<
180 : : ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
181 : : getAccessibleStateSet (void)
182 : : throw (::com::sun::star::uno::RuntimeException);
183 : :
184 : : /** Return the parents locale or throw exception if this object has no
185 : : parent yet/anymore.
186 : : */
187 : : virtual ::com::sun::star::lang::Locale SAL_CALL
188 : : getLocale (void)
189 : : throw (::com::sun::star::uno::RuntimeException,
190 : : ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
191 : :
192 : : //===== XAccessibleComponent ================================================
193 : :
194 : : virtual sal_Bool SAL_CALL containsPoint (
195 : : const ::com::sun::star::awt::Point& aPoint)
196 : : throw (::com::sun::star::uno::RuntimeException);
197 : :
198 : : virtual ::com::sun::star::uno::Reference<
199 : : ::com::sun::star::accessibility::XAccessible > SAL_CALL
200 : : getAccessibleAtPoint (
201 : : const ::com::sun::star::awt::Point& aPoint)
202 : : throw (::com::sun::star::uno::RuntimeException);
203 : :
204 : : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
205 : : throw (::com::sun::star::uno::RuntimeException);
206 : :
207 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
208 : : throw (::com::sun::star::uno::RuntimeException);
209 : :
210 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
211 : : throw (::com::sun::star::uno::RuntimeException);
212 : :
213 : : virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
214 : : throw (::com::sun::star::uno::RuntimeException);
215 : :
216 : : virtual void SAL_CALL grabFocus (void)
217 : : throw (::com::sun::star::uno::RuntimeException);
218 : :
219 : : virtual sal_Int32 SAL_CALL getForeground (void)
220 : : throw (::com::sun::star::uno::RuntimeException);
221 : :
222 : : virtual sal_Int32 SAL_CALL getBackground (void)
223 : : throw (::com::sun::star::uno::RuntimeException);
224 : :
225 : :
226 : : //===== XServiceInfo ====================================================
227 : :
228 : : /** Returns an identifier for the implementation of this object.
229 : : */
230 : : virtual ::rtl::OUString SAL_CALL
231 : : getImplementationName (void)
232 : : throw (::com::sun::star::uno::RuntimeException);
233 : :
234 : : /** Return whether the specified service is supported by this class.
235 : : */
236 : : virtual sal_Bool SAL_CALL
237 : : supportsService (const ::rtl::OUString& sServiceName)
238 : : throw (::com::sun::star::uno::RuntimeException);
239 : :
240 : : /** Returns a list of all supported services.
241 : : */
242 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
243 : : getSupportedServiceNames (void)
244 : : throw (::com::sun::star::uno::RuntimeException);
245 : :
246 : :
247 : : protected:
248 : : ::com::sun::star::uno::Reference<
249 : : ::com::sun::star::accessibility::XAccessible> mxParent;
250 : : ::sd::toolpanel::TreeNode& mrTreeNode;
251 : : ::rtl::Reference< ::utl::AccessibleStateSetHelper> mrStateSet;
252 : :
253 : : const ::rtl::OUString msName;
254 : : const ::rtl::OUString msDescription;
255 : : const sal_Int16 meRole;
256 : :
257 : : virtual ~AccessibleTreeNode (void);
258 : :
259 : : /** Check whether or not the object has been disposed (or is in the
260 : : state of beeing disposed). If that is the case then
261 : : DisposedException is thrown to inform the (indirect) caller of the
262 : : foul deed.
263 : : */
264 : : void ThrowIfDisposed (void)
265 : : throw (::com::sun::star::lang::DisposedException);
266 : :
267 : : /** Check whether or not the object has been disposed (or is in the
268 : : state of beeing disposed).
269 : :
270 : : @return sal_True, if the object is disposed or in the course
271 : : of being disposed. Otherwise, sal_False is returned.
272 : : */
273 : : sal_Bool IsDisposed (void);
274 : :
275 : : /** Update the mpStateSet member to reflect the current state of the
276 : : TreeNode. When one of the states has changed since the last call
277 : : then an appropriate event is sent.
278 : : */
279 : : virtual void UpdateStateSet (void);
280 : :
281 : : /** Update a single state and sent an event if its value changes.
282 : : */
283 : : void UpdateState(
284 : : sal_Int16 aState,
285 : : bool bValue);
286 : :
287 : : DECL_LINK(StateChangeListener, ::sd::toolpanel::TreeNodeStateChangeEvent*);
288 : : DECL_LINK(WindowEventListener, VclWindowEvent*);
289 : :
290 : : private:
291 : : sal_uInt32 mnClientId;
292 : :
293 : : /// The common part of the constructor.
294 : : void CommonConstructor (void);
295 : : };
296 : :
297 : : } // end of namespace ::accessibility
298 : :
299 : : #endif
300 : :
301 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|