bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / inc / AccessibleTreeNode.hxx
blobf1a3a5094a57eb3271c55c060f6c4adf23b3c6e2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
21 #define SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
23 #include "MutexOwner.hxx"
24 #include <cppuhelper/compbase5.hxx>
25 #include <com/sun/star/accessibility/XAccessible.hpp>
26 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
27 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
28 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/lang/DisposedException.hpp>
33 #include <com/sun/star/awt/XFocusListener.hpp>
34 #include <com/sun/star/document/XEventListener.hpp>
35 #include <unotools/accessiblestatesethelper.hxx>
36 #include <tools/link.hxx>
37 #include <rtl/ref.hxx>
39 class VclWindowEvent;
41 namespace sd { namespace toolpanel {
42 class TreeNode;
43 class TreeNodeStateChangeEvent;
44 } }
47 namespace utl {
48 class AccessibleStateSetHelper;
51 namespace accessibility {
54 typedef ::cppu::PartialWeakComponentImplHelper5<
55 ::com::sun::star::accessibility::XAccessible,
56 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
57 ::com::sun::star::accessibility::XAccessibleContext,
58 ::com::sun::star::accessibility::XAccessibleComponent,
59 ::com::sun::star::lang::XServiceInfo
60 > AccessibleTreeNodeBase;
62 /** This class makes objects based on the sd::toolpanel::TreeNode
63 accessible.
65 class AccessibleTreeNode
66 : public ::sd::MutexOwner,
67 public AccessibleTreeNodeBase
69 public:
70 /** Create a new object for the given tree node. The accessible parent
71 is taken from the window returned by GetAccessibleParent() when
72 called at the window of the node.
73 @param rNode
74 The TreeNode to make accessible.
75 @param rsName
76 The accessible name that will be returned by getAccessibleName().
77 @param rsDescription
78 The accessible description that will be returned by
79 getAccessibleDescription().
80 @param eRole
81 The role that will be returned by getAccessibleRole().
83 AccessibleTreeNode(
84 ::sd::toolpanel::TreeNode& rNode,
85 const OUString& rsName,
86 const OUString& rsDescription,
87 sal_Int16 eRole);
89 void FireAccessibleEvent (
90 short nEventId,
91 const ::com::sun::star::uno::Any& rOldValue,
92 const ::com::sun::star::uno::Any& rNewValue);
94 virtual void SAL_CALL disposing (void);
96 //===== XComponent =======================================================
98 virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
99 { WeakComponentImplHelperBase::dispose(); }
100 virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
101 { WeakComponentImplHelperBase::addEventListener(xListener); }
102 virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
103 { WeakComponentImplHelperBase::removeEventListener(xListener); }
105 //===== XAccessible =======================================================
107 virtual ::com::sun::star::uno::Reference<
108 ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
109 getAccessibleContext (void)
110 throw (::com::sun::star::uno::RuntimeException);
113 //===== XAccessibleEventBroadcaster =======================================
115 virtual void SAL_CALL
116 addAccessibleEventListener(
117 const ::com::sun::star::uno::Reference<
118 ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener)
119 throw (::com::sun::star::uno::RuntimeException);
121 virtual void SAL_CALL
122 removeAccessibleEventListener(
123 const ::com::sun::star::uno::Reference<
124 ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener )
125 throw (::com::sun::star::uno::RuntimeException);
127 //===== XAccessibleContext ==============================================
129 /// Return the number of currently visible children.
130 virtual sal_Int32 SAL_CALL
131 getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
133 /// Return the specified child or throw exception.
134 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
135 getAccessibleChild (sal_Int32 nIndex)
136 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
138 /// Return a reference to the parent.
139 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
140 getAccessibleParent (void)
141 throw (::com::sun::star::uno::RuntimeException);
143 /// Return this objects index among the parents children.
144 virtual sal_Int32 SAL_CALL
145 getAccessibleIndexInParent (void)
146 throw (::com::sun::star::uno::RuntimeException);
148 /// Return this object's role.
149 virtual sal_Int16 SAL_CALL
150 getAccessibleRole (void)
151 throw (::com::sun::star::uno::RuntimeException);
153 /// Return this object's description.
154 virtual OUString SAL_CALL
155 getAccessibleDescription (void)
156 throw (::com::sun::star::uno::RuntimeException);
158 /// Return the object's current name.
159 virtual OUString SAL_CALL
160 getAccessibleName (void)
161 throw (::com::sun::star::uno::RuntimeException);
163 /// Return NULL to indicate that an empty relation set.
164 virtual ::com::sun::star::uno::Reference<
165 ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
166 getAccessibleRelationSet (void)
167 throw (::com::sun::star::uno::RuntimeException);
169 /// Return the set of current states.
170 virtual ::com::sun::star::uno::Reference<
171 ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
172 getAccessibleStateSet (void)
173 throw (::com::sun::star::uno::RuntimeException);
175 /** Return the parents locale or throw exception if this object has no
176 parent yet/anymore.
178 virtual ::com::sun::star::lang::Locale SAL_CALL
179 getLocale (void)
180 throw (::com::sun::star::uno::RuntimeException,
181 ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
183 //===== XAccessibleComponent ================================================
185 virtual sal_Bool SAL_CALL containsPoint (
186 const ::com::sun::star::awt::Point& aPoint)
187 throw (::com::sun::star::uno::RuntimeException);
189 virtual ::com::sun::star::uno::Reference<
190 ::com::sun::star::accessibility::XAccessible > SAL_CALL
191 getAccessibleAtPoint (
192 const ::com::sun::star::awt::Point& aPoint)
193 throw (::com::sun::star::uno::RuntimeException);
195 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
196 throw (::com::sun::star::uno::RuntimeException);
198 virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
199 throw (::com::sun::star::uno::RuntimeException);
201 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
202 throw (::com::sun::star::uno::RuntimeException);
204 virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
205 throw (::com::sun::star::uno::RuntimeException);
207 virtual void SAL_CALL grabFocus (void)
208 throw (::com::sun::star::uno::RuntimeException);
210 virtual sal_Int32 SAL_CALL getForeground (void)
211 throw (::com::sun::star::uno::RuntimeException);
213 virtual sal_Int32 SAL_CALL getBackground (void)
214 throw (::com::sun::star::uno::RuntimeException);
217 //===== XServiceInfo ====================================================
219 /** Returns an identifier for the implementation of this object.
221 virtual OUString SAL_CALL
222 getImplementationName (void)
223 throw (::com::sun::star::uno::RuntimeException);
225 /** Return whether the specified service is supported by this class.
227 virtual sal_Bool SAL_CALL
228 supportsService (const OUString& sServiceName)
229 throw (::com::sun::star::uno::RuntimeException);
231 /** Returns a list of all supported services.
233 virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL
234 getSupportedServiceNames (void)
235 throw (::com::sun::star::uno::RuntimeException);
238 protected:
239 ::com::sun::star::uno::Reference<
240 ::com::sun::star::accessibility::XAccessible> mxParent;
241 ::sd::toolpanel::TreeNode& mrTreeNode;
242 ::rtl::Reference< ::utl::AccessibleStateSetHelper> mrStateSet;
244 const OUString msName;
245 const OUString msDescription;
246 const sal_Int16 meRole;
248 virtual ~AccessibleTreeNode (void);
250 /** Check whether or not the object has been disposed (or is in the
251 state of beeing disposed). If that is the case then
252 DisposedException is thrown to inform the (indirect) caller of the
253 foul deed.
255 void ThrowIfDisposed (void)
256 throw (::com::sun::star::lang::DisposedException);
258 /** Check whether or not the object has been disposed (or is in the
259 state of beeing disposed).
261 @return sal_True, if the object is disposed or in the course
262 of being disposed. Otherwise, sal_False is returned.
264 sal_Bool IsDisposed (void);
266 /** Update the mpStateSet member to reflect the current state of the
267 TreeNode. When one of the states has changed since the last call
268 then an appropriate event is sent.
270 virtual void UpdateStateSet (void);
272 /** Update a single state and sent an event if its value changes.
274 void UpdateState(
275 sal_Int16 aState,
276 bool bValue);
278 DECL_LINK(StateChangeListener, ::sd::toolpanel::TreeNodeStateChangeEvent*);
279 DECL_LINK(WindowEventListener, VclWindowEvent*);
281 private:
282 sal_uInt32 mnClientId;
284 /// The common part of the constructor.
285 void CommonConstructor (void);
288 } // end of namespace ::accessibility
290 #endif
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */