1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <osl/mutex.hxx>
21 #include <tools/color.hxx>
22 #include <tools/string.hxx>
23 #include <vcl/image.hxx>
24 #include <cppuhelper/implbase5.hxx>
25 #include <cppuhelper/compbase6.hxx>
26 #include <comphelper/broadcasthelper.hxx>
27 #include <com/sun/star/lang/XUnoTunnel.hpp>
28 #include <com/sun/star/accessibility/XAccessible.hpp>
29 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
30 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
31 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
32 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
33 #include <com/sun/star/lang/DisposedException.hpp>
37 #define VALUESET_ITEM_NONEITEM 0xFFFE
59 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>* mpxAcc
;
61 ValueSetItem( ValueSet
& rParent
);
64 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
65 GetAccessible( bool bIsTransientChildrenDisabled
);
68 typedef ::cppu::PartialWeakComponentImplHelper6
<
69 ::com::sun::star::accessibility::XAccessible
,
70 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
71 ::com::sun::star::accessibility::XAccessibleContext
,
72 ::com::sun::star::accessibility::XAccessibleComponent
,
73 ::com::sun::star::accessibility::XAccessibleSelection
,
74 ::com::sun::star::lang::XUnoTunnel
>
75 ValueSetAccComponentBase
;
78 public ::comphelper::OBaseMutex
,
79 public ValueSetAccComponentBase
83 ValueSetAcc( ValueSet
* pParent
, bool bIsTransientChildrenDisabled
);
86 void FireAccessibleEvent( short nEventId
, const ::com::sun::star::uno::Any
& rOldValue
, const ::com::sun::star::uno::Any
& rNewValue
);
87 sal_Bool
HasAccessibleListeners() const { return( mxEventListeners
.size() > 0 ); }
89 static ValueSetAcc
* getImplementation( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxData
) throw();
93 /** Called by the corresponding ValueSet when it gets the focus.
94 Stores the new focus state and broadcasts a state change event.
98 /** Called by the corresponding ValueSet when it loses the focus.
99 Stores the new focus state and broadcasts a state change event.
101 void LoseFocus (void);
104 virtual void SAL_CALL
dispose()throw (::com::sun::star::uno::RuntimeException
)
105 { WeakComponentImplHelperBase::dispose(); }
106 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & xListener
)throw (::com::sun::star::uno::RuntimeException
)
107 { WeakComponentImplHelperBase::addEventListener(xListener
); }
108 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & xListener
)throw (::com::sun::star::uno::RuntimeException
)
109 { WeakComponentImplHelperBase::removeEventListener(xListener
); }
112 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
);
114 // XAccessibleEventBroadcaster
115 virtual void SAL_CALL
addAccessibleEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
removeAccessibleEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
118 // XAccessibleContext
119 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
121 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
122 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException
);
123 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
124 virtual OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
125 virtual OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
126 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
127 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
128 virtual ::com::sun::star::lang::Locale SAL_CALL
getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException
, ::com::sun::star::uno::RuntimeException
);
130 // XAccessibleComponent
131 virtual sal_Bool SAL_CALL
containsPoint( const ::com::sun::star::awt::Point
& aPoint
) throw (::com::sun::star::uno::RuntimeException
);
132 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const ::com::sun::star::awt::Point
& aPoint
) throw (::com::sun::star::uno::RuntimeException
);
133 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds( ) throw (::com::sun::star::uno::RuntimeException
);
134 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation( ) throw (::com::sun::star::uno::RuntimeException
);
135 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException
);
136 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( ) throw (::com::sun::star::uno::RuntimeException
);
137 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
138 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
139 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
140 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
142 // XAccessibleSelection
143 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
144 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
145 virtual void SAL_CALL
clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException
);
146 virtual void SAL_CALL
selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException
);
147 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
148 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
149 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
152 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw( ::com::sun::star::uno::RuntimeException
);
155 ::std::vector
< ::com::sun::star::uno::Reference
<
156 ::com::sun::star::accessibility::XAccessibleEventListener
> > mxEventListeners
;
158 bool mbIsTransientChildrenDisabled
;
159 /// The current FOCUSED state.
162 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
164 /** Tell all listeners that the object is dying. This callback is
165 usually called from the WeakComponentImplHelper class.
167 virtual void SAL_CALL
disposing (void);
169 /** Return the number of items. This takes the None-Item into account.
171 sal_uInt16
getItemCount (void) const;
173 /** Return the item associated with the given index. The None-Item is
174 taken into account which, when present, is taken to be the first
177 Index of the item to return. The index 0 denotes the None-Item
180 Returns NULL when the given index is out of range.
182 ValueSetItem
* getItem (sal_uInt16 nIndex
) const;
184 /** Check whether or not the object has been disposed (or is in the
185 state of beeing disposed). If that is the case then
186 DisposedException is thrown to inform the (indirect) caller of the
189 void ThrowIfDisposed (void)
190 throw (::com::sun::star::lang::DisposedException
);
192 /** Check whether the value set has a 'none' field, i.e. a field (button)
193 that deselects any items (selects none of them).
195 Returns <true/> if there is a 'none' field and <false/> it it is
198 bool HasNoneField (void) const;
201 class ValueItemAcc
: public ::cppu::WeakImplHelper5
< ::com::sun::star::accessibility::XAccessible
,
202 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
203 ::com::sun::star::accessibility::XAccessibleContext
,
204 ::com::sun::star::accessibility::XAccessibleComponent
,
205 ::com::sun::star::lang::XUnoTunnel
>
209 ::std::vector
< ::com::sun::star::uno::Reference
<
210 ::com::sun::star::accessibility::XAccessibleEventListener
> > mxEventListeners
;
211 ::osl::Mutex maMutex
;
212 ValueSetItem
* mpParent
;
213 bool mbIsTransientChildrenDisabled
;
215 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
219 ValueItemAcc( ValueSetItem
* pParent
, bool bIsTransientChildrenDisabled
);
222 void ParentDestroyed();
224 void FireAccessibleEvent( short nEventId
, const ::com::sun::star::uno::Any
& rOldValue
, const ::com::sun::star::uno::Any
& rNewValue
);
225 sal_Bool
HasAccessibleListeners() const { return( mxEventListeners
.size() > 0 ); }
227 static ValueItemAcc
* getImplementation( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxData
) throw();
232 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
);
234 // XAccessibleEventBroadcaster
235 virtual void SAL_CALL
addAccessibleEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
236 virtual void SAL_CALL
removeAccessibleEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
238 // XAccessibleContext
239 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
240 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
241 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
242 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException
);
243 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
244 virtual OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
245 virtual OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
246 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
247 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
248 virtual ::com::sun::star::lang::Locale SAL_CALL
getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException
, ::com::sun::star::uno::RuntimeException
);
250 // XAccessibleComponent
251 virtual sal_Bool SAL_CALL
containsPoint( const ::com::sun::star::awt::Point
& aPoint
) throw (::com::sun::star::uno::RuntimeException
);
252 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const ::com::sun::star::awt::Point
& aPoint
) throw (::com::sun::star::uno::RuntimeException
);
253 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds( ) throw (::com::sun::star::uno::RuntimeException
);
254 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation( ) throw (::com::sun::star::uno::RuntimeException
);
255 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException
);
256 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( ) throw (::com::sun::star::uno::RuntimeException
);
257 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
258 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
259 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
260 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
263 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw( ::com::sun::star::uno::RuntimeException
);
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */