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 _SVXPIXELACCESSIBLECONTEXT_HXX
23 #define _SVXPIXELACCESSIBLECONTEXT_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 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESELECTION_HPP_
41 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEVALUE_HPP_
44 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
45 #endif
46
47 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
48 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
49 #endif
50 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
51 #include <com/sun/star/uno/Reference.hxx>
52 #endif
53 #ifndef _CPPUHELPER_WEAK_HXX_
54 #include <cppuhelper/weak.hxx>
55 #endif
56 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
57 #include <com/sun/star/lang/XServiceInfo.hpp>
58 #endif
59 #ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
60 #include <com/sun/star/lang/XTypeProvider.hpp>
61 #endif
62 #ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
63 #include <com/sun/star/lang/XServiceName.hpp>
64 #endif
65 #ifndef _COM_SUN_STAR_LANG_INDEXOUTOFBOUNDSEXCEPTION_HPP_
66 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
67 #endif
68 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
69 #include <com/sun/star/lang/DisposedException.hpp>
70 #endif
71 #ifndef _VOS_MUTEX_HXX_
72 #include <vos/mutex.hxx>
73 #endif
74 #ifndef _CPPUHELPER_INTERFACECONTAINER_H_
75 #include <cppuhelper/interfacecontainer.h>
76 #endif
77 #ifndef _CPPUHELPER_COMPBASE6_HXX_
78 #include <cppuhelper/compbase6.hxx>
79 #endif
80 #ifndef _CPPUHELPER_COMPBASE7_HXX_
81 #include <cppuhelper/compbase7.hxx>
82 #endif
83 #ifndef _CPPUHELPER_COMPBASE5_HXX_
84 #include <cppuhelper/compbase5.hxx>
85 #endif
86 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
87 #include <comphelper/broadcasthelper.hxx>
88 #endif
89 #ifndef _CPPUHELPER_IMPLBASE6_HXX_
90 #include <cppuhelper/implbase6.hxx>
91 #endif
92 #include <comphelper/servicehelper.hxx>
93
94 //#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETABLE_HPP_
95 //#include <com/sun/star/accessibility/XAccessibleTable.hpp>
96 //#endif
97
98 #ifndef _SVX_RECTENUM_HXX //autogen
99 #include <rectenum.hxx>
100 #endif
101
102
103 #include <tools/gen.hxx>
104
105
106 namespace com { namespace sun { namespace star { namespace awt {
107 struct Point;
108 struct Rectangle;
109 struct Size;
110 class XFocusListener;
111 } } } };
112 class SvxPixelCtl;
113
114
115 typedef ::cppu::WeakAggComponentImplHelper5<
116 ::com::sun::star::accessibility::XAccessible,
117 ::com::sun::star::accessibility::XAccessibleComponent,
118 ::com::sun::star::accessibility::XAccessibleContext,
119 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
120 ::com::sun::star::lang::XServiceInfo >
121 SvxPixelCtlAccessibleChild_BASE;
122
123 class SvxPixelCtlAccessibleChild :
124 public ::comphelper::OBaseMutex,
125 public SvxPixelCtlAccessibleChild_BASE
126 {
127 SvxPixelCtl* mrParentWindow;
128 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxParent;
129 void IsValid();
130 sal_Bool m_bPixelColorOrBG;//Pixel Color Or BackGround Color
131 Point maPoint;
132 Rectangle* mpBoundingBox;
133 /// index of child in parent
134 long mnIndexInParent;
135 /// Mutex guarding this object.
136 ::osl::Mutex m_aMutex;
137 public:
138 SvxPixelCtlAccessibleChild(
139 SvxPixelCtl* rWindow,
140 sal_Bool bPixelColorOrBG,
141 const Point& aPoint,
142 const Rectangle& rBounds,
143 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& xParent,
144 long nIndexInParent );
145 ~SvxPixelCtlAccessibleChild();
146
147 //XAccessible
148 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( );
149
150 //XAccessibleContext
151 virtual sal_Int32 SAL_CALL getAccessibleChildCount( );
152 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i );
153 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( );
154 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( );
155 virtual sal_Int16 SAL_CALL getAccessibleRole( );
156 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( );
157 virtual ::rtl::OUString SAL_CALL getAccessibleName( );
158 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( );
159 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( );
160 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( );
161
162
163 //XAccessibleComponent
164 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint );
165 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint );
166 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( );
167 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( );
168 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( );
169 virtual ::com::sun::star::awt::Size SAL_CALL getSize( );
170 virtual sal_Int32 SAL_CALL getForeground( );
171 virtual sal_Int32 SAL_CALL getBackground( );
172 virtual void SAL_CALL grabFocus( );
173
174 //XServiceInfo
175 virtual ::rtl::OUString SAL_CALL getImplementationName( );
176 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
177 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( );
178
179 //Methods for XAccessibleEventBroadcaster
180 sal_uInt32 mnClientId;
181
182 virtual void SAL_CALL
183 addEventListener(
184 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener );
185
186 virtual void SAL_CALL
187 removeEventListener(
188 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener );
189 void CommitChange( const com::sun::star::accessibility::AccessibleEventObject& rEvent );
190
191 //Solution: Add the event handling method
192 void FireAccessibleEvent (short nEventId, const ::com::sun::star::uno::Any& rOld, const ::com::sun::star::uno::Any& rNew);
193 virtual void SAL_CALL disposing();
194
195 virtual Rectangle GetBoundingBoxOnScreen( void );
196
197 virtual Rectangle GetBoundingBox( void );
198
199 /// @returns true if it's disposed or in disposing
200 inline sal_Bool IsAlive( void ) const;
201 /// @returns true if it's not disposed and no in disposing
202 inline sal_Bool IsNotAlive( void ) const;
203 /// throws the exception DisposedException if it's not alive
204 void ThrowExceptionIfNotAlive( void );
205
206
207 void CheckChild();
208 void SelectChild( sal_Bool bSelect);
ChangePixelColorOrBG(sal_Bool bPixelColorOrBG)209 void ChangePixelColorOrBG(sal_Bool bPixelColorOrBG){ m_bPixelColorOrBG = bPixelColorOrBG ;}
210 ::rtl::OUString GetName();
211 };
212
213
214 typedef ::cppu::WeakAggComponentImplHelper6<
215 ::com::sun::star::accessibility::XAccessible,
216 ::com::sun::star::accessibility::XAccessibleComponent,
217 ::com::sun::star::accessibility::XAccessibleContext,
218 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
219 ::com::sun::star::accessibility::XAccessibleSelection,
220 // ::com::sun::star::accessibility::XAccessibleTable,
221 ::com::sun::star::lang::XServiceInfo >
222 SvxPixelCtlAccessible_BASE;
223
224 class SvxPixelCtlAccessible :
225 public ::comphelper::OBaseMutex,
226 public SvxPixelCtlAccessible_BASE
227 {
228 SvxPixelCtl* pPixelCtl;
229 void IsValid();
230
231 public:
232 SvxPixelCtlAccessible(SvxPixelCtl& rWindow);
233 ~SvxPixelCtlAccessible();
234
235 void ensureIsAlive() const;
236
237 //XAccessible
238 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( );
239
240 //XAccessibleContext
241 virtual sal_Int32 SAL_CALL getAccessibleChildCount( );
242 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i );
243 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( );
244 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( );
245 virtual sal_Int16 SAL_CALL getAccessibleRole( );
246 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( );
247 virtual ::rtl::OUString SAL_CALL getAccessibleName( );
248 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( );
249 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( );
250 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( );
251
252
253 //XAccessibleComponent
254 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint );
255 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint );
256 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( );
257 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( );
258 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( );
259 virtual ::com::sun::star::awt::Size SAL_CALL getSize( );
260 virtual sal_Int32 SAL_CALL getForeground( );
261 virtual sal_Int32 SAL_CALL getBackground( );
262 virtual void SAL_CALL grabFocus( );
263 //XServiceInfo
264 virtual ::rtl::OUString SAL_CALL getImplementationName( );
265 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
266 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( );
267 // XAccessibleSelection
268 void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex );
269 sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex );
270 void SAL_CALL clearAccessibleSelection( );
271 void SAL_CALL selectAllAccessibleChildren( );
272 sal_Int32 SAL_CALL getSelectedAccessibleChildCount( );
273 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex );
274 void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex );
275
276 /*
277 // XAccessibleTable -------------------------------------------------------
278 /-** @return The number of used rows in the table (0 = empty table). *-/
279 virtual sal_Int32 SAL_CALL getAccessibleRowCount() throw ( ::com::sun::star::uno::RuntimeException );
280 /-** @return The number of used columns in the table (0 = empty table). *-/
281 virtual sal_Int32 SAL_CALL getAccessibleColumnCount() throw ( ::com::sun::star::uno::RuntimeException );
282 /-** @return The row extent of the specified cell (always 1). *-/
283 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
284 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
285 ::com::sun::star::uno::RuntimeException );
286 /-** @return The column extent of the specified cell (always 1). *-/
287 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
288 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
289 ::com::sun::star::uno::RuntimeException );
290 /-** @return The caption cell of the table (not supported). *-/
291 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
292 getAccessibleCaption() throw ( ::com::sun::star::uno::RuntimeException );
293 /-** @return The summary object of the table (not supported). *-/
294 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
295 getAccessibleSummary() throw ( ::com::sun::star::uno::RuntimeException );
296 /-** @return The child index of the specified cell. *-/
297 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
298 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
299 /-** @return The row index of the specified child cell. *-/
300 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
301 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
302 /-** @return The column index of the specified child cell. *-/
303 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
304 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
305 /-** @return The description text of the specified row. *-/
306 virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow )
307 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
308 /-** @return The description text of the specified column. *-/
309 virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn )
310 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
311 /-** @return The XAccessibleTable interface of the row header bar. *-/
312 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
313 getAccessibleRowHeaders() throw ( ::com::sun::star::uno::RuntimeException );
314 /-** @return The XAccessibleTable interface of the column header bar. *-/
315 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
316 getAccessibleColumnHeaders() throw ( ::com::sun::star::uno::RuntimeException );
317 /-** @return An index list of completely selected rows. *-/
318 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
319 getSelectedAccessibleRows() throw ( ::com::sun::star::uno::RuntimeException );
320 /-** @return An index list of completely selected columns. *-/
321 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
322 getSelectedAccessibleColumns() throw ( ::com::sun::star::uno::RuntimeException );
323 /-** @return <TRUE/>, if the specified row is completely selected. *-/
324 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
325 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
326 /-** @return <TRUE/>, if the specified column is completely selected. *-/
327 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
328 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
329 /-** @return The XAccessible interface of the cell object at the specified cell position. *-/
330 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
331 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
332 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
333 ::com::sun::star::uno::RuntimeException );
334 /-** @return <TRUE/>, if the specified cell is selected. *-/
335 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
336 throw ( ::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException );
337
338 */
339 //Methods for XAccessibleEventBroadcaster
340 sal_uInt32 mnClientId;
341
342 virtual void SAL_CALL
343 addEventListener(
344 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener );
345
346 virtual void SAL_CALL
347 removeEventListener(
348 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener );
349 void CommitChange( const com::sun::star::accessibility::AccessibleEventObject& rEvent );
350 //Solution: Add the event handling method
351 void FireAccessibleEvent (short nEventId, const ::com::sun::star::uno::Any& rOld, const ::com::sun::star::uno::Any& rNew);
352 virtual void SAL_CALL disposing();
353
354 /// select child
355 void SelectChild( Point pos );
356 void SelectChild( long nIndex);
357 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
358 CreateChild (long nIndex, Point mPoint);
359
360
361 void LoseFocus();
362
363 void Invalidate();
364 /// @returns true if it's disposed or in disposing
365 inline sal_Bool IsAlive( void ) const;
366 /// @returns true if it's not disposed and no in disposing
367 inline sal_Bool IsNotAlive( void ) const;
368 /// throws the exception DisposedException if it's not alive
369 void ThrowExceptionIfNotAlive( void );
370
371 protected:
372 /** @attention This method requires locked mutex's and a living object.
373 @throws <type>IndexOutOfBoundsException</type>
374 If the specified row index is invalid. */
375 void ensureIsValidRow( sal_Int32 nRow );
376 /** @attention This method requires locked mutex's and a living object.
377 @throws <type>IndexOutOfBoundsException</type>
378 If the specified column index is invalid. */
379 void ensureIsValidColumn( sal_Int32 nColumn );
380 /** @attention This method requires locked mutex's and a living object.
381 @throws <type>IndexOutOfBoundsException</type>
382 If the specified cell address is invalid. */
383 void ensureIsValidAddress( sal_Int32 nRow, sal_Int32 nColumn );
384 /** @attention This method requires locked mutex's and a living object.
385 @throws <type>IndexOutOfBoundsException</type>
386 If the specified child index is invalid. */
387 void ensureIsValidIndex( sal_Int32 nChildIndex );
388
389
390 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> m_xCurChild;
391 public:
392 void NotifyChild(long nIndex,sal_Bool bSelect ,sal_Bool bCheck);
393 };
394
IsAlive(void) const395 inline sal_Bool SvxPixelCtlAccessible::IsAlive( void ) const
396 {
397 return !rBHelper.bDisposed && !rBHelper.bInDispose;
398 }
399
IsNotAlive(void) const400 inline sal_Bool SvxPixelCtlAccessible::IsNotAlive( void ) const
401 {
402 return rBHelper.bDisposed || rBHelper.bInDispose;
403 }
404
IsAlive(void) const405 inline sal_Bool SvxPixelCtlAccessibleChild::IsAlive( void ) const
406 {
407 return !rBHelper.bDisposed && !rBHelper.bInDispose;
408 }
409
IsNotAlive(void) const410 inline sal_Bool SvxPixelCtlAccessibleChild::IsNotAlive( void ) const
411 {
412 return rBHelper.bDisposed || rBHelper.bInDispose;
413 }
414
415
416 #endif
417