1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svxrectctaccessiblecontext.hxx,v $
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 ************************************************************************/
32 #ifndef _SVXRECTACCESSIBLECONTEXT_HXX
33 #define _SVXRECTACCESSIBLECONTEXT_HXX
35 #include <com/sun/star/accessibility/XAccessible.hpp>
36 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
37 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
38 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
39 #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
40 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
41 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
42 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
43 #include <com/sun/star/uno/Reference.hxx>
44 #include <cppuhelper/weak.hxx>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/lang/XTypeProvider.hpp>
47 #include <com/sun/star/lang/XServiceName.hpp>
48 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
49 #include <com/sun/star/lang/DisposedException.hpp>
50 #include <vos/mutex.hxx>
51 #include <cppuhelper/interfacecontainer.h>
52 #include <cppuhelper/compbase6.hxx>
53 //#ifndef _CPPUHELPER_COMPBASE7_HXX_
54 //#include <cppuhelper/compbase7.hxx>
56 #include <comphelper/broadcasthelper.hxx>
57 #include <cppuhelper/implbase6.hxx>
58 #include <comphelper/servicehelper.hxx>
59 #include <svx/rectenum.hxx>
61 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
70 class SvxRectCtlChildAccessibleContext
;
74 typedef ::cppu::WeakAggComponentImplHelper6
<
75 ::com::sun::star::accessibility::XAccessible
,
76 ::com::sun::star::accessibility::XAccessibleComponent
,
77 ::com::sun::star::accessibility::XAccessibleContext
,
78 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
79 ::com::sun::star::accessibility::XAccessibleSelection
,
80 ::com::sun::star::lang::XServiceInfo
>
81 SvxRectCtlAccessibleContext_Base
;
83 class SvxRectCtlAccessibleContext
: public ::comphelper::OBaseMutex
, public SvxRectCtlAccessibleContext_Base
86 //===== internal ========================================================
87 SvxRectCtlAccessibleContext(
88 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& rxParent
,
89 SvxRectCtl
& rRepresentation
,
90 const ::rtl::OUString
* pName
= NULL
,
91 const ::rtl::OUString
* pDescription
= NULL
);
93 virtual ~SvxRectCtlAccessibleContext();
95 //===== XAccessible =====================================================
97 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
98 getAccessibleContext( void ) throw( ::com::sun::star::uno::RuntimeException
);
100 //===== XAccessibleComponent ============================================
102 virtual sal_Bool SAL_CALL
103 containsPoint( const ::com::sun::star::awt::Point
& rPoint
) throw( ::com::sun::star::uno::RuntimeException
);
105 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
106 getAccessibleAtPoint( const ::com::sun::star::awt::Point
& rPoint
) throw( ::com::sun::star::uno::RuntimeException
);
108 virtual ::com::sun::star::awt::Rectangle SAL_CALL
109 getBounds() throw( ::com::sun::star::uno::RuntimeException
);
111 virtual ::com::sun::star::awt::Point SAL_CALL
112 getLocation() throw( ::com::sun::star::uno::RuntimeException
);
114 virtual ::com::sun::star::awt::Point SAL_CALL
115 getLocationOnScreen() throw( ::com::sun::star::uno::RuntimeException
);
117 virtual ::com::sun::star::awt::Size SAL_CALL
118 getSize() throw( ::com::sun::star::uno::RuntimeException
);
120 virtual sal_Bool SAL_CALL
121 isShowing() throw( ::com::sun::star::uno::RuntimeException
);
123 virtual sal_Bool SAL_CALL
124 isVisible() throw( ::com::sun::star::uno::RuntimeException
);
126 virtual sal_Bool SAL_CALL
127 isFocusTraversable() throw( ::com::sun::star::uno::RuntimeException
);
129 virtual void SAL_CALL
131 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
)
132 throw( ::com::sun::star::uno::RuntimeException
);
134 virtual void SAL_CALL
136 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
)
137 throw( ::com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
140 grabFocus() throw( ::com::sun::star::uno::RuntimeException
);
142 virtual ::com::sun::star::uno::Any SAL_CALL
143 getAccessibleKeyBinding() throw( ::com::sun::star::uno::RuntimeException
);
144 virtual sal_Int32 SAL_CALL
145 getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
146 virtual sal_Int32 SAL_CALL
147 getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
149 //===== XAccessibleContext ==============================================
151 virtual sal_Int32 SAL_CALL
152 getAccessibleChildCount( void ) throw( ::com::sun::star::uno::RuntimeException
);
154 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
155 getAccessibleChild( sal_Int32 nIndex
)
156 throw( ::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::IndexOutOfBoundsException
);
158 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
159 getAccessibleParent( void ) throw( ::com::sun::star::uno::RuntimeException
);
161 virtual sal_Int32 SAL_CALL
162 getAccessibleIndexInParent( void ) throw( ::com::sun::star::uno::RuntimeException
);
164 virtual sal_Int16 SAL_CALL
165 getAccessibleRole( void ) throw( ::com::sun::star::uno::RuntimeException
);
167 virtual ::rtl::OUString SAL_CALL
168 getAccessibleDescription( void ) throw (::com::sun::star::uno::RuntimeException
);
170 virtual ::rtl::OUString SAL_CALL
171 getAccessibleName( void ) throw (::com::sun::star::uno::RuntimeException
);
173 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
174 getAccessibleRelationSet( void ) throw( ::com::sun::star::uno::RuntimeException
);
176 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
177 getAccessibleStateSet( void ) throw( ::com::sun::star::uno::RuntimeException
);
179 virtual ::com::sun::star::lang::Locale SAL_CALL
181 throw( ::com::sun::star::uno::RuntimeException
,
182 ::com::sun::star::accessibility::IllegalAccessibleComponentStateException
);
184 //===== XComponent =====================================================
186 using ::cppu::WeakAggComponentImplHelperBase::addEventListener
;
187 using ::cppu::WeakAggComponentImplHelperBase::removeEventListener
;
189 //===== XAccessibleEventBroadcaster =====================================
191 virtual void SAL_CALL
193 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
194 throw( com::sun::star::uno::RuntimeException
);
196 virtual void SAL_CALL
198 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
199 throw( com::sun::star::uno::RuntimeException
);
201 //===== XServiceInfo ====================================================
203 virtual ::rtl::OUString SAL_CALL
204 getImplementationName( void ) throw( ::com::sun::star::uno::RuntimeException
);
206 virtual sal_Bool SAL_CALL
207 supportsService( const ::rtl::OUString
& sServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
209 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
210 getSupportedServiceNames( void ) throw( ::com::sun::star::uno::RuntimeException
);
212 //===== XTypeProvider ===================================================
214 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
215 getImplementationId( void ) throw( ::com::sun::star::uno::RuntimeException
);
217 //===== XAccessibleSelection =============================================
219 virtual void SAL_CALL
220 selectAccessibleChild( sal_Int32 nChildIndex
)
221 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
223 virtual sal_Bool SAL_CALL
224 isAccessibleChildSelected( sal_Int32 nChildIndex
)
225 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
227 virtual void SAL_CALL
228 clearAccessibleSelection() throw( ::com::sun::star::uno::RuntimeException
);
230 virtual void SAL_CALL
231 selectAllAccessibleChildren() throw( ::com::sun::star::uno::RuntimeException
);
233 virtual sal_Int32 SAL_CALL
234 getSelectedAccessibleChildCount() throw( ::com::sun::star::uno::RuntimeException
);
236 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
237 getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
238 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
240 virtual void SAL_CALL
241 deselectAccessibleChild( sal_Int32 nSelectedChildIndex
)
242 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
246 //===== internals ========================================================
248 void checkChildIndex( long nIndexOfChild
) throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
250 void checkChildIndexOnSelection( long nIndexOfChild
) throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
252 /** Selects a new child by index.
254 <p>If the child was not selected before, the state of the child will
255 be updated. If the index is invalid, the index will internaly set to NOCHILDSELECTED</p>
258 Index of the new child which should be selected.
260 void selectChild( long nIndexOfChild
);
263 /** Selects a new child by point.
265 <p>If the child was not selected before, the state of the child will
266 be updated. If the point is not invalid, the index will internaly set to NOCHILDSELECTED</p>
269 Button which belongs to the child which should be selected.
271 void selectChild( RECT_POINT ePoint
);
274 void setName( const ::rtl::OUString
& rName
);
276 /// Sets the description
277 void setDescription( const ::rtl::OUString
& rDescr
);
279 static ::com::sun::star::uno::Sequence
< sal_Int8
> getUniqueId( void );
282 /// @Return the object's current bounding box relative to the desktop.
283 virtual Rectangle
GetBoundingBoxOnScreen( void ) throw( ::com::sun::star::uno::RuntimeException
);
285 /// @Return the object's current bounding box relative to the parent object.
286 virtual Rectangle
GetBoundingBox( void ) throw( ::com::sun::star::uno::RuntimeException
);
288 /// Calls all Listener to tell they the change.
289 void CommitChange( const com::sun::star::accessibility::AccessibleEventObject
& rEvent
);
291 virtual void SAL_CALL
disposing();
293 /// @returns true if it's disposed or in disposing
294 inline sal_Bool
IsAlive( void ) const;
296 /// @returns true if it's not disposed and no in disposing
297 inline sal_Bool
IsNotAlive( void ) const;
299 /// throws the exception DisposedException if it's not alive
300 void ThrowExceptionIfNotAlive( void ) throw( ::com::sun::star::lang::DisposedException
);
303 /** Description of this object. This is not a constant because it can
304 be set from the outside.
306 ::rtl::OUString msDescription
;
308 /** Name of this object.
310 ::rtl::OUString msName
;
312 /// Reference to the parent object.
313 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
316 /// pointer to internal representation
319 /// array for all possible childs
320 SvxRectCtlChildAccessibleContext
** mpChilds
;
322 /// client id in the AccessibleEventNotifier queue
323 sal_uInt32 mnClientId
;
325 /// actual selected child
326 long mnSelectedChild
;
328 /// mode of control (true -> 8 points, false -> 9 points)
329 sal_Bool mbAngleMode
;
332 inline sal_Bool
SvxRectCtlAccessibleContext::IsAlive( void ) const
334 return !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
;
337 inline sal_Bool
SvxRectCtlAccessibleContext::IsNotAlive( void ) const
339 return rBHelper
.bDisposed
|| rBHelper
.bInDispose
;
343 typedef ::cppu::WeakAggComponentImplHelper6
<
344 ::com::sun::star::accessibility::XAccessible
,
345 ::com::sun::star::accessibility::XAccessibleComponent
,
346 ::com::sun::star::accessibility::XAccessibleContext
,
347 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
348 ::com::sun::star::accessibility::XAccessibleValue
,
349 ::com::sun::star::lang::XServiceInfo
>
350 SvxRectCtlChildAccessibleContext_Base
;
353 class SvxRectCtlChildAccessibleContext
: public SvxRectCtlChildAccessibleContext_Base
356 SvxRectCtlChildAccessibleContext(
357 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& rxParent
,
358 const Window
& rParentWindow
,
359 const ::rtl::OUString
& rName
, const ::rtl::OUString
& rDescription
,
360 const Rectangle
& rBoundingBox
,
361 long nIndexInParent
);
363 virtual ~SvxRectCtlChildAccessibleContext();
365 //===== XAccessible =====================================================
367 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
368 getAccessibleContext( void ) throw( ::com::sun::star::uno::RuntimeException
);
370 //===== XAccessibleComponent ============================================
372 virtual sal_Bool SAL_CALL
373 containsPoint( const ::com::sun::star::awt::Point
& rPoint
) throw( ::com::sun::star::uno::RuntimeException
);
375 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
376 getAccessibleAtPoint( const ::com::sun::star::awt::Point
& rPoint
) throw( ::com::sun::star::uno::RuntimeException
);
378 virtual ::com::sun::star::awt::Rectangle SAL_CALL
379 getBounds() throw( ::com::sun::star::uno::RuntimeException
);
381 virtual ::com::sun::star::awt::Point SAL_CALL
382 getLocation() throw( ::com::sun::star::uno::RuntimeException
);
384 virtual ::com::sun::star::awt::Point SAL_CALL
385 getLocationOnScreen() throw( ::com::sun::star::uno::RuntimeException
);
387 virtual ::com::sun::star::awt::Size SAL_CALL
388 getSize() throw( ::com::sun::star::uno::RuntimeException
);
390 virtual sal_Bool SAL_CALL
391 isShowing() throw( ::com::sun::star::uno::RuntimeException
);
393 virtual sal_Bool SAL_CALL
394 isVisible() throw( ::com::sun::star::uno::RuntimeException
);
396 virtual sal_Bool SAL_CALL
397 isFocusTraversable() throw( ::com::sun::star::uno::RuntimeException
);
399 virtual void SAL_CALL
400 addFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
)
401 throw( ::com::sun::star::uno::RuntimeException
);
403 virtual void SAL_CALL
404 removeFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
)
405 throw (::com::sun::star::uno::RuntimeException
);
407 virtual void SAL_CALL
408 grabFocus() throw( ::com::sun::star::uno::RuntimeException
);
410 virtual ::com::sun::star::uno::Any SAL_CALL
411 getAccessibleKeyBinding() throw( ::com::sun::star::uno::RuntimeException
);
412 virtual sal_Int32 SAL_CALL
413 getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
414 virtual sal_Int32 SAL_CALL
415 getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
417 //===== XAccessibleContext ==============================================
419 virtual sal_Int32 SAL_CALL
420 getAccessibleChildCount( void ) throw( ::com::sun::star::uno::RuntimeException
);
422 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
423 getAccessibleChild( sal_Int32 nIndex
)
424 throw( ::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::IndexOutOfBoundsException
);
426 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
427 getAccessibleParent( void ) throw( ::com::sun::star::uno::RuntimeException
);
429 virtual sal_Int32 SAL_CALL
430 getAccessibleIndexInParent( void ) throw( ::com::sun::star::uno::RuntimeException
);
432 virtual sal_Int16 SAL_CALL
433 getAccessibleRole( void ) throw( ::com::sun::star::uno::RuntimeException
);
435 virtual ::rtl::OUString SAL_CALL
436 getAccessibleDescription( void ) throw( ::com::sun::star::uno::RuntimeException
);
438 virtual ::rtl::OUString SAL_CALL
439 getAccessibleName( void ) throw( ::com::sun::star::uno::RuntimeException
);
441 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
442 getAccessibleRelationSet( void ) throw( ::com::sun::star::uno::RuntimeException
);
444 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
445 getAccessibleStateSet( void ) throw( ::com::sun::star::uno::RuntimeException
);
447 virtual ::com::sun::star::lang::Locale SAL_CALL
449 throw( ::com::sun::star::uno::RuntimeException
, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException
);
451 //===== XComponent =====================================================
453 using ::cppu::WeakAggComponentImplHelperBase::addEventListener
;
454 using ::cppu::WeakAggComponentImplHelperBase::removeEventListener
;
456 //===== XAccessibleEventBroadcaster =====================================
458 virtual void SAL_CALL
460 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
461 throw( ::com::sun::star::uno::RuntimeException
);
463 virtual void SAL_CALL
465 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
466 throw( com::sun::star::uno::RuntimeException
);
468 //===== XAccessibleValue ================================================
470 virtual ::com::sun::star::uno::Any SAL_CALL
471 getCurrentValue() throw( ::com::sun::star::uno::RuntimeException
);
473 virtual sal_Bool SAL_CALL
474 setCurrentValue( const ::com::sun::star::uno::Any
& aNumber
) throw( ::com::sun::star::uno::RuntimeException
);
476 virtual ::com::sun::star::uno::Any SAL_CALL
477 getMaximumValue() throw( ::com::sun::star::uno::RuntimeException
);
479 virtual ::com::sun::star::uno::Any SAL_CALL
480 getMinimumValue() throw( ::com::sun::star::uno::RuntimeException
);
482 //===== XServiceInfo ====================================================
484 virtual ::rtl::OUString SAL_CALL
485 getImplementationName( void ) throw( ::com::sun::star::uno::RuntimeException
);
487 virtual sal_Bool SAL_CALL
488 supportsService( const ::rtl::OUString
& sServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
490 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
491 getSupportedServiceNames( void ) throw( ::com::sun::star::uno::RuntimeException
);
494 //===== XTypeProvider ===================================================
496 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
497 getImplementationId( void ) throw( ::com::sun::star::uno::RuntimeException
);
499 //===== internal ==========================================================
501 /// Sets the checked status
502 void setStateChecked( sal_Bool bChecked
);
505 virtual Rectangle
GetBoundingBoxOnScreen( void ) throw( ::com::sun::star::uno::RuntimeException
);
507 virtual Rectangle
GetBoundingBox( void ) throw( ::com::sun::star::uno::RuntimeException
);
509 void CommitChange( const com::sun::star::accessibility::AccessibleEventObject
& rEvent
);
511 virtual void SAL_CALL
disposing();
513 /// @returns true if it's disposed or in disposing
514 inline sal_Bool
IsAlive( void ) const;
516 /// @returns true if it's not disposed and no in disposing
517 inline sal_Bool
IsNotAlive( void ) const;
519 /// throws the exception DisposedException if it's not alive
520 void ThrowExceptionIfNotAlive( void ) throw( ::com::sun::star::lang::DisposedException
);
522 /// Mutex guarding this object.
523 ::osl::Mutex maMutex
;
527 /** Description of this object. This is not a constant because it can
528 be set from the outside. Furthermore, it changes according the the
529 draw page's display mode.
531 ::rtl::OUString msDescription
;
533 /** Name of this object. It changes according the the draw page's
536 ::rtl::OUString msName
;
538 /// Reference to the parent object.
539 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
543 Rectangle
* mpBoundingBox
;
546 const Window
& mrParentWindow
;
548 /// client id in the AccessibleEventNotifier queue
549 sal_uInt32 mnClientId
;
551 /// index of child in parent
552 long mnIndexInParent
;
554 /// Indicates, if object is checked
555 sal_Bool mbIsChecked
;
558 inline sal_Bool
SvxRectCtlChildAccessibleContext::IsAlive( void ) const
560 return !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
;
563 inline sal_Bool
SvxRectCtlChildAccessibleContext::IsNotAlive( void ) const
565 return rBHelper
.bDisposed
|| rBHelper
.bInDispose
;