update dev300-m58
[ooovba.git] / sd / source / ui / inc / AccessibleTreeNode.hxx
blobf860a5dfd6dbb13d60456d9f414a5cee3ad388c2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleTreeNode.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
32 #define SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
34 #include "MutexOwner.hxx"
35 #include <cppuhelper/compbase5.hxx>
36 #include <com/sun/star/accessibility/XAccessible.hpp>
37 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
38 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
39 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
40 #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/DisposedException.hpp>
44 #include <com/sun/star/awt/XFocusListener.hpp>
45 #include <com/sun/star/document/XEventListener.hpp>
46 #include <unotools/accessiblestatesethelper.hxx>
47 #include <tools/link.hxx>
48 #include <rtl/ref.hxx>
50 class VclWindowEvent;
52 namespace sd { namespace toolpanel {
53 class TreeNode;
54 class TreeNodeStateChangeEvent;
55 } }
58 namespace utl {
59 class AccessibleStateSetHelper;
62 namespace accessibility {
65 class AccessibleSlideSorterObject;
67 typedef ::cppu::WeakComponentImplHelper5<
68 ::com::sun::star::accessibility::XAccessible,
69 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
70 ::com::sun::star::accessibility::XAccessibleContext,
71 ::com::sun::star::accessibility::XAccessibleComponent,
72 ::com::sun::star::lang::XServiceInfo
73 > AccessibleTreeNodeBase;
75 /** This class makes objects based on the sd::toolpanel::TreeNode
76 accessible.
78 class AccessibleTreeNode
79 : public ::sd::MutexOwner,
80 public AccessibleTreeNodeBase
82 public:
83 /** Create a new object for the given tree node. The accessible parent
84 is taken from the window returned by GetAccessibleParent() when
85 called at the window of the node.
86 @param rNode
87 The TreeNode to make accessible.
88 @param rsName
89 The accessible name that will be returned by getAccessibleName().
90 @param rsDescription
91 The accessible description that will be returned by
92 getAccessibleDescription().
93 @param eRole
94 The role that will be returned by getAccessibleRole().
96 AccessibleTreeNode(
97 ::sd::toolpanel::TreeNode& rNode,
98 const ::rtl::OUString& rsName,
99 const ::rtl::OUString& rsDescription,
100 sal_Int16 eRole);
102 /** Use this variant of the constructor when the accessible parent is
103 non-standard.
104 @param rxParent
105 The accessible parent that will be returned by
106 getAccessibleParent() and that is used for computing relative
107 coordinates.
108 @param rNode
109 The TreeNode to make accessible.
110 @param rsName
111 The accessible name that will be returned by getAccessibleName().
112 @param rsDescription
113 The accessible description that will be returned by
114 getAccessibleDescription().
115 @param eRole
116 The role that will be returned by getAccessibleRole().
118 AccessibleTreeNode(
119 const ::com::sun::star::uno::Reference<
120 ::com::sun::star::accessibility::XAccessible> & rxParent,
121 ::sd::toolpanel::TreeNode& rNode,
122 const ::rtl::OUString& rsName,
123 const ::rtl::OUString& rsDescription,
124 sal_Int16 eRole);
126 void FireAccessibleEvent (
127 short nEventId,
128 const ::com::sun::star::uno::Any& rOldValue,
129 const ::com::sun::star::uno::Any& rNewValue);
131 virtual void SAL_CALL disposing (void);
133 //===== XAccessible =======================================================
135 virtual ::com::sun::star::uno::Reference<
136 ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
137 getAccessibleContext (void)
138 throw (::com::sun::star::uno::RuntimeException);
141 //===== XAccessibleEventBroadcaster =======================================
143 virtual void SAL_CALL
144 addEventListener(
145 const ::com::sun::star::uno::Reference<
146 ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener)
147 throw (::com::sun::star::uno::RuntimeException);
149 virtual void SAL_CALL
150 removeEventListener(
151 const ::com::sun::star::uno::Reference<
152 ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener )
153 throw (::com::sun::star::uno::RuntimeException);
155 using cppu::WeakComponentImplHelperBase::addEventListener;
156 using cppu::WeakComponentImplHelperBase::removeEventListener;
158 //===== XAccessibleContext ==============================================
160 /// Return the number of currently visible children.
161 virtual sal_Int32 SAL_CALL
162 getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
164 /// Return the specified child or throw exception.
165 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
166 getAccessibleChild (sal_Int32 nIndex)
167 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
169 /// Return a reference to the parent.
170 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
171 getAccessibleParent (void)
172 throw (::com::sun::star::uno::RuntimeException);
174 /// Return this objects index among the parents children.
175 virtual sal_Int32 SAL_CALL
176 getAccessibleIndexInParent (void)
177 throw (::com::sun::star::uno::RuntimeException);
179 /// Return this object's role.
180 virtual sal_Int16 SAL_CALL
181 getAccessibleRole (void)
182 throw (::com::sun::star::uno::RuntimeException);
184 /// Return this object's description.
185 virtual ::rtl::OUString SAL_CALL
186 getAccessibleDescription (void)
187 throw (::com::sun::star::uno::RuntimeException);
189 /// Return the object's current name.
190 virtual ::rtl::OUString SAL_CALL
191 getAccessibleName (void)
192 throw (::com::sun::star::uno::RuntimeException);
194 /// Return NULL to indicate that an empty relation set.
195 virtual ::com::sun::star::uno::Reference<
196 ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
197 getAccessibleRelationSet (void)
198 throw (::com::sun::star::uno::RuntimeException);
200 /// Return the set of current states.
201 virtual ::com::sun::star::uno::Reference<
202 ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
203 getAccessibleStateSet (void)
204 throw (::com::sun::star::uno::RuntimeException);
206 /** Return the parents locale or throw exception if this object has no
207 parent yet/anymore.
209 virtual ::com::sun::star::lang::Locale SAL_CALL
210 getLocale (void)
211 throw (::com::sun::star::uno::RuntimeException,
212 ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
214 //===== XAccessibleComponent ================================================
216 virtual sal_Bool SAL_CALL containsPoint (
217 const ::com::sun::star::awt::Point& aPoint)
218 throw (::com::sun::star::uno::RuntimeException);
220 virtual ::com::sun::star::uno::Reference<
221 ::com::sun::star::accessibility::XAccessible > SAL_CALL
222 getAccessibleAtPoint (
223 const ::com::sun::star::awt::Point& aPoint)
224 throw (::com::sun::star::uno::RuntimeException);
226 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
227 throw (::com::sun::star::uno::RuntimeException);
229 virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
230 throw (::com::sun::star::uno::RuntimeException);
232 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
233 throw (::com::sun::star::uno::RuntimeException);
235 virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
236 throw (::com::sun::star::uno::RuntimeException);
238 virtual void SAL_CALL grabFocus (void)
239 throw (::com::sun::star::uno::RuntimeException);
241 virtual sal_Int32 SAL_CALL getForeground (void)
242 throw (::com::sun::star::uno::RuntimeException);
244 virtual sal_Int32 SAL_CALL getBackground (void)
245 throw (::com::sun::star::uno::RuntimeException);
248 //===== XServiceInfo ====================================================
250 /** Returns an identifier for the implementation of this object.
252 virtual ::rtl::OUString SAL_CALL
253 getImplementationName (void)
254 throw (::com::sun::star::uno::RuntimeException);
256 /** Return whether the specified service is supported by this class.
258 virtual sal_Bool SAL_CALL
259 supportsService (const ::rtl::OUString& sServiceName)
260 throw (::com::sun::star::uno::RuntimeException);
262 /** Returns a list of all supported services.
264 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
265 getSupportedServiceNames (void)
266 throw (::com::sun::star::uno::RuntimeException);
269 protected:
270 ::com::sun::star::uno::Reference<
271 ::com::sun::star::accessibility::XAccessible> mxParent;
272 ::sd::toolpanel::TreeNode& mrTreeNode;
273 ::rtl::Reference< ::utl::AccessibleStateSetHelper> mrStateSet;
275 const ::rtl::OUString msName;
276 const ::rtl::OUString msDescription;
277 const sal_Int16 meRole;
279 virtual ~AccessibleTreeNode (void);
281 /** Check whether or not the object has been disposed (or is in the
282 state of beeing disposed). If that is the case then
283 DisposedException is thrown to inform the (indirect) caller of the
284 foul deed.
286 void ThrowIfDisposed (void)
287 throw (::com::sun::star::lang::DisposedException);
289 /** Check whether or not the object has been disposed (or is in the
290 state of beeing disposed).
292 @return sal_True, if the object is disposed or in the course
293 of being disposed. Otherwise, sal_False is returned.
295 sal_Bool IsDisposed (void);
297 /** Update the mpStateSet member to reflect the current state of the
298 TreeNode. When one of the states has changed since the last call
299 then an appropriate event is sent.
301 virtual void UpdateStateSet (void);
303 /** Update a single state and sent an event if its value changes.
305 void UpdateState(
306 sal_Int16 aState,
307 bool bValue);
309 DECL_LINK(StateChangeListener, ::sd::toolpanel::TreeNodeStateChangeEvent*);
310 DECL_LINK(WindowEventListener, VclWindowEvent*);
312 private:
313 sal_uInt32 mnClientId;
315 /// The common part of the constructor.
316 void CommonConstructor (void);
319 } // end of namespace ::accessibility
321 #endif