1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
29 #define SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX
31 #include "MutexOwner.hxx"
32 #include <cppuhelper/compbase5.hxx>
33 #include <com/sun/star/accessibility/XAccessible.hpp>
34 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
35 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
36 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
37 #include <com/sun/star/accessibility/AccessibleRole.hpp>
38 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/lang/DisposedException.hpp>
41 #include <com/sun/star/awt/XFocusListener.hpp>
42 #include <com/sun/star/document/XEventListener.hpp>
43 #include <unotools/accessiblestatesethelper.hxx>
44 #include <tools/link.hxx>
45 #include <rtl/ref.hxx>
49 namespace sd
{ namespace toolpanel
{
51 class TreeNodeStateChangeEvent
;
56 class AccessibleStateSetHelper
;
59 namespace accessibility
{
62 class AccessibleSlideSorterObject
;
64 typedef ::cppu::WeakComponentImplHelper5
<
65 ::com::sun::star::accessibility::XAccessible
,
66 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
67 ::com::sun::star::accessibility::XAccessibleContext
,
68 ::com::sun::star::accessibility::XAccessibleComponent
,
69 ::com::sun::star::lang::XServiceInfo
70 > AccessibleTreeNodeBase
;
72 /** This class makes objects based on the sd::toolpanel::TreeNode
75 class AccessibleTreeNode
76 : public ::sd::MutexOwner
,
77 public AccessibleTreeNodeBase
80 /** Create a new object for the given tree node. The accessible parent
81 is taken from the window returned by GetAccessibleParent() when
82 called at the window of the node.
84 The TreeNode to make accessible.
86 The accessible name that will be returned by getAccessibleName().
88 The accessible description that will be returned by
89 getAccessibleDescription().
91 The role that will be returned by getAccessibleRole().
94 ::sd::toolpanel::TreeNode
& rNode
,
95 const ::rtl::OUString
& rsName
,
96 const ::rtl::OUString
& rsDescription
,
99 void FireAccessibleEvent (
101 const ::com::sun::star::uno::Any
& rOldValue
,
102 const ::com::sun::star::uno::Any
& rNewValue
);
104 virtual void SAL_CALL
disposing (void);
106 //===== XAccessible =======================================================
108 virtual ::com::sun::star::uno::Reference
<
109 ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
110 getAccessibleContext (void)
111 throw (::com::sun::star::uno::RuntimeException
);
114 //===== XAccessibleEventBroadcaster =======================================
116 virtual void SAL_CALL
118 const ::com::sun::star::uno::Reference
<
119 ::com::sun::star::accessibility::XAccessibleEventListener
>& rxListener
)
120 throw (::com::sun::star::uno::RuntimeException
);
122 virtual void SAL_CALL
124 const ::com::sun::star::uno::Reference
<
125 ::com::sun::star::accessibility::XAccessibleEventListener
>& rxListener
)
126 throw (::com::sun::star::uno::RuntimeException
);
128 using cppu::WeakComponentImplHelperBase::addEventListener
;
129 using cppu::WeakComponentImplHelperBase::removeEventListener
;
131 //===== XAccessibleContext ==============================================
133 /// Return the number of currently visible children.
134 virtual sal_Int32 SAL_CALL
135 getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException
);
137 /// Return the specified child or throw exception.
138 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
139 getAccessibleChild (sal_Int32 nIndex
)
140 throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
142 /// Return a reference to the parent.
143 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
144 getAccessibleParent (void)
145 throw (::com::sun::star::uno::RuntimeException
);
147 /// Return this objects index among the parents children.
148 virtual sal_Int32 SAL_CALL
149 getAccessibleIndexInParent (void)
150 throw (::com::sun::star::uno::RuntimeException
);
152 /// Return this object's role.
153 virtual sal_Int16 SAL_CALL
154 getAccessibleRole (void)
155 throw (::com::sun::star::uno::RuntimeException
);
157 /// Return this object's description.
158 virtual ::rtl::OUString SAL_CALL
159 getAccessibleDescription (void)
160 throw (::com::sun::star::uno::RuntimeException
);
162 /// Return the object's current name.
163 virtual ::rtl::OUString SAL_CALL
164 getAccessibleName (void)
165 throw (::com::sun::star::uno::RuntimeException
);
167 /// Return NULL to indicate that an empty relation set.
168 virtual ::com::sun::star::uno::Reference
<
169 ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
170 getAccessibleRelationSet (void)
171 throw (::com::sun::star::uno::RuntimeException
);
173 /// Return the set of current states.
174 virtual ::com::sun::star::uno::Reference
<
175 ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
176 getAccessibleStateSet (void)
177 throw (::com::sun::star::uno::RuntimeException
);
179 /** Return the parents locale or throw exception if this object has no
182 virtual ::com::sun::star::lang::Locale SAL_CALL
184 throw (::com::sun::star::uno::RuntimeException
,
185 ::com::sun::star::accessibility::IllegalAccessibleComponentStateException
);
187 //===== XAccessibleComponent ================================================
189 virtual sal_Bool SAL_CALL
containsPoint (
190 const ::com::sun::star::awt::Point
& aPoint
)
191 throw (::com::sun::star::uno::RuntimeException
);
193 virtual ::com::sun::star::uno::Reference
<
194 ::com::sun::star::accessibility::XAccessible
> SAL_CALL
195 getAccessibleAtPoint (
196 const ::com::sun::star::awt::Point
& aPoint
)
197 throw (::com::sun::star::uno::RuntimeException
);
199 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds (void)
200 throw (::com::sun::star::uno::RuntimeException
);
202 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation (void)
203 throw (::com::sun::star::uno::RuntimeException
);
205 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen (void)
206 throw (::com::sun::star::uno::RuntimeException
);
208 virtual ::com::sun::star::awt::Size SAL_CALL
getSize (void)
209 throw (::com::sun::star::uno::RuntimeException
);
211 virtual void SAL_CALL
grabFocus (void)
212 throw (::com::sun::star::uno::RuntimeException
);
214 virtual sal_Int32 SAL_CALL
getForeground (void)
215 throw (::com::sun::star::uno::RuntimeException
);
217 virtual sal_Int32 SAL_CALL
getBackground (void)
218 throw (::com::sun::star::uno::RuntimeException
);
221 //===== XServiceInfo ====================================================
223 /** Returns an identifier for the implementation of this object.
225 virtual ::rtl::OUString SAL_CALL
226 getImplementationName (void)
227 throw (::com::sun::star::uno::RuntimeException
);
229 /** Return whether the specified service is supported by this class.
231 virtual sal_Bool SAL_CALL
232 supportsService (const ::rtl::OUString
& sServiceName
)
233 throw (::com::sun::star::uno::RuntimeException
);
235 /** Returns a list of all supported services.
237 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
238 getSupportedServiceNames (void)
239 throw (::com::sun::star::uno::RuntimeException
);
243 ::com::sun::star::uno::Reference
<
244 ::com::sun::star::accessibility::XAccessible
> mxParent
;
245 ::sd::toolpanel::TreeNode
& mrTreeNode
;
246 ::rtl::Reference
< ::utl::AccessibleStateSetHelper
> mrStateSet
;
248 const ::rtl::OUString msName
;
249 const ::rtl::OUString msDescription
;
250 const sal_Int16 meRole
;
252 virtual ~AccessibleTreeNode (void);
254 /** Check whether or not the object has been disposed (or is in the
255 state of beeing disposed). If that is the case then
256 DisposedException is thrown to inform the (indirect) caller of the
259 void ThrowIfDisposed (void)
260 throw (::com::sun::star::lang::DisposedException
);
262 /** Check whether or not the object has been disposed (or is in the
263 state of beeing disposed).
265 @return sal_True, if the object is disposed or in the course
266 of being disposed. Otherwise, sal_False is returned.
268 sal_Bool
IsDisposed (void);
270 /** Update the mpStateSet member to reflect the current state of the
271 TreeNode. When one of the states has changed since the last call
272 then an appropriate event is sent.
274 virtual void UpdateStateSet (void);
276 /** Update a single state and sent an event if its value changes.
282 DECL_LINK(StateChangeListener
, ::sd::toolpanel::TreeNodeStateChangeEvent
*);
283 DECL_LINK(WindowEventListener
, VclWindowEvent
*);
286 sal_uInt32 mnClientId
;
288 /// The common part of the constructor.
289 void CommonConstructor (void);
292 } // end of namespace ::accessibility