nss: upgrade to release 3.73
[LibreOffice.git] / svtools / source / control / valueimp.hxx
blob5f874acb99db8447dab8c92fd1aafd6cf5b3521d
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 #pragma once
22 #include <osl/mutex.hxx>
23 #include <tools/color.hxx>
24 #include <vcl/image.hxx>
25 #include <cppuhelper/implbase.hxx>
26 #include <cppuhelper/compbase.hxx>
27 #include <cppuhelper/basemutex.hxx>
28 #include <com/sun/star/lang/XUnoTunnel.hpp>
29 #include <com/sun/star/accessibility/XAccessible.hpp>
30 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
31 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
32 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
33 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
35 #include <vector>
37 #define VALUESET_ITEM_NONEITEM 0xFFFE
39 enum ValueSetItemType
41 VALUESETITEM_NONE,
42 VALUESETITEM_IMAGE,
43 VALUESETITEM_IMAGE_AND_TEXT,
44 VALUESETITEM_COLOR,
45 VALUESETITEM_USERDRAW
48 class ValueItemAcc;
49 class ValueSet;
51 struct ValueSetItem
53 ValueSet& mrParent;
54 sal_uInt16 mnId;
55 sal_uInt8 meType;
56 bool mbVisible;
57 Image maImage;
58 Color maColor;
59 OUString maText;
60 void* mpData;
61 rtl::Reference< ValueItemAcc > mxAcc;
63 explicit ValueSetItem( ValueSet& rParent );
64 ~ValueSetItem();
66 css::uno::Reference< css::accessibility::XAccessible >
67 GetAccessible( bool bIsTransientChildrenDisabled );
70 typedef ::cppu::WeakComponentImplHelper<
71 css::accessibility::XAccessible,
72 css::accessibility::XAccessibleEventBroadcaster,
73 css::accessibility::XAccessibleContext,
74 css::accessibility::XAccessibleComponent,
75 css::accessibility::XAccessibleSelection,
76 css::lang::XUnoTunnel >
77 ValueSetAccComponentBase;
79 class ValueSetAcc :
80 public ::cppu::BaseMutex,
81 public ValueSetAccComponentBase
83 public:
85 explicit ValueSetAcc(ValueSet* pParent);
86 virtual ~ValueSetAcc() override;
88 void FireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue );
89 bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
91 static ValueSetAcc* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw();
93 public:
95 /** Called by the corresponding ValueSet when it gets the focus.
96 Stores the new focus state and broadcasts a state change event.
98 void GetFocus();
100 /** Called by the corresponding ValueSet when it loses the focus.
101 Stores the new focus state and broadcasts a state change event.
103 void LoseFocus();
105 // XAccessible
106 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
108 // XAccessibleEventBroadcaster
109 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
110 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
112 // XAccessibleContext
113 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
114 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
115 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
116 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
117 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
118 virtual OUString SAL_CALL getAccessibleDescription( ) override;
119 virtual OUString SAL_CALL getAccessibleName( ) override;
120 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
121 virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
122 virtual css::lang::Locale SAL_CALL getLocale( ) override;
124 // XAccessibleComponent
125 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
126 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
127 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
128 virtual css::awt::Point SAL_CALL getLocation( ) override;
129 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
130 virtual css::awt::Size SAL_CALL getSize( ) override;
131 virtual void SAL_CALL grabFocus( ) override;
132 virtual sal_Int32 SAL_CALL getForeground( ) override;
133 virtual sal_Int32 SAL_CALL getBackground( ) override;
135 // XAccessibleSelection
136 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override;
137 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override;
138 virtual void SAL_CALL clearAccessibleSelection( ) override;
139 virtual void SAL_CALL selectAllAccessibleChildren( ) override;
140 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
141 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
142 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
144 // XUnoTunnel
145 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
146 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
148 private:
149 ::std::vector< css::uno::Reference<
150 css::accessibility::XAccessibleEventListener > > mxEventListeners;
151 ValueSet* mpParent;
152 /// The current FOCUSED state.
153 bool mbIsFocused;
155 /** Tell all listeners that the object is dying. This callback is
156 usually called from the WeakComponentImplHelper class.
158 virtual void SAL_CALL disposing() override;
160 /** Return the number of items. This takes the None-Item into account.
162 sal_uInt16 getItemCount() const;
164 /** Return the item associated with the given index. The None-Item is
165 taken into account which, when present, is taken to be the first
166 (with index 0) item.
167 @param nIndex
168 Index of the item to return. The index 0 denotes the None-Item
169 when present.
170 @return
171 Returns NULL when the given index is out of range.
173 ValueSetItem* getItem (sal_uInt16 nIndex) const;
175 /** Check whether or not the object has been disposed (or is in the
176 state of being disposed). If that is the case then
177 DisposedException is thrown to inform the (indirect) caller of the
178 foul deed.
179 @throws css::lang::DisposedException
181 void ThrowIfDisposed();
183 /** Check whether the value set has a 'none' field, i.e. a field (button)
184 that deselects any items (selects none of them).
185 @return
186 Returns <true/> if there is a 'none' field and <false/> if it is
187 missing.
189 bool HasNoneField() const;
192 class ValueItemAcc : public ::cppu::WeakImplHelper< css::accessibility::XAccessible,
193 css::accessibility::XAccessibleEventBroadcaster,
194 css::accessibility::XAccessibleContext,
195 css::accessibility::XAccessibleComponent,
196 css::lang::XUnoTunnel >
198 private:
200 ::std::vector< css::uno::Reference<
201 css::accessibility::XAccessibleEventListener > > mxEventListeners;
202 ::osl::Mutex maMutex;
203 ValueSetItem* mpParent;
204 bool mbIsTransientChildrenDisabled;
206 public:
208 ValueItemAcc(ValueSetItem* pParent, bool bIsTransientChildrenDisabled);
209 virtual ~ValueItemAcc() override;
211 void ParentDestroyed();
213 void FireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue );
215 static ValueItemAcc* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) throw();
217 public:
219 // XAccessible
220 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
222 // XAccessibleEventBroadcaster
223 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
224 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
226 // XAccessibleContext
227 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
228 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
229 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
230 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
231 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
232 virtual OUString SAL_CALL getAccessibleDescription( ) override;
233 virtual OUString SAL_CALL getAccessibleName( ) override;
234 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
235 virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
236 virtual css::lang::Locale SAL_CALL getLocale( ) override;
238 // XAccessibleComponent
239 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
240 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
241 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
242 virtual css::awt::Point SAL_CALL getLocation( ) override;
243 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
244 virtual css::awt::Size SAL_CALL getSize( ) override;
245 virtual void SAL_CALL grabFocus( ) override;
246 virtual sal_Int32 SAL_CALL getForeground( ) override;
247 virtual sal_Int32 SAL_CALL getBackground( ) override;
249 // XUnoTunnel
250 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
251 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */