LibreOffice Module framework (master) 1
actiontriggerpropertyset.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <vcl/svapp.hxx>
27
28using namespace cppu;
29using namespace com::sun::star::uno;
30using namespace com::sun::star::beans;
31using namespace com::sun::star::lang;
32using namespace com::sun::star::awt;
33
34//struct SAL_DLLPUBLIC_IMPORT ::cppu::OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper, OMultiTypeInterfaceContainerHelper::keyType >;
35
36namespace {
37
38// Handles for properties
39// (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
40// We use an enum to define these handles, to use all numbers from 0 to nn and
41// if you add someone, you don't must control this!
42// But don't forget to change values of follow defines, if you do something with this enum!
43enum EPROPERTIES
44{
45 HANDLE_COMMANDURL,
46 HANDLE_HELPURL,
47 HANDLE_IMAGE,
48 HANDLE_SUBCONTAINER,
49 HANDLE_TEXT,
51};
52
53}
54
55namespace framework
56{
57
60 , OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) )
61{
62}
63
65{
66}
67
68// XInterface
70{
71 Any a = ::cppu::queryInterface(
72 aType,
73 static_cast< XServiceInfo* >(this),
74 static_cast< XTypeProvider* >(this));
75
76 if( a.hasValue() )
77 return a;
78 else
79 {
80 a = OPropertySetHelper::queryInterface( aType );
81
82 if( a.hasValue() )
83 return a;
84 }
85
86 return OWeakObject::queryInterface( aType );
87}
88
89void SAL_CALL ActionTriggerPropertySet::acquire() noexcept
90{
91 OWeakObject::acquire();
92}
93
94void SAL_CALL ActionTriggerPropertySet::release() noexcept
95{
96 OWeakObject::release();
97}
98
99// XServiceInfo
101{
103}
104
105sal_Bool SAL_CALL ActionTriggerPropertySet::supportsService( const OUString& ServiceName )
106{
108}
109
111{
113 return seqServiceNames;
114}
115
116// XTypeProvider
118{
119 // Create a static typecollection ...
120 static ::cppu::OTypeCollection ourTypeCollection(
126
127
128 return ourTypeCollection.getTypes();
129}
130
132{
133 return css::uno::Sequence<sal_Int8>();
134}
135
137 Any& aConvertedValue,
138 Any& aOldValue,
139 sal_Int32 nHandle,
140 const Any& aValue )
141{
142 // Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
143 // Return sal_True, if changed - else return sal_False.
144 // Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
145 // Initialize return value with sal_False !!!
146 // (Handle can be invalid)
147 bool bReturn = false;
148
149 switch( nHandle )
150 {
151 case HANDLE_COMMANDURL:
152 bReturn = impl_tryToChangeProperty( m_aCommandURL, aValue, aOldValue, aConvertedValue );
153 break;
154
155 case HANDLE_HELPURL:
156 bReturn = impl_tryToChangeProperty( m_aHelpURL, aValue, aOldValue, aConvertedValue );
157 break;
158
159 case HANDLE_IMAGE:
160 bReturn = impl_tryToChangeProperty( m_xBitmap, aValue, aOldValue, aConvertedValue );
161 break;
162
163 case HANDLE_SUBCONTAINER:
164 bReturn = impl_tryToChangeProperty( m_xActionTriggerContainer, aValue, aOldValue, aConvertedValue );
165 break;
166
167 case HANDLE_TEXT:
168 bReturn = impl_tryToChangeProperty( m_aText, aValue, aOldValue, aConvertedValue );
169 break;
170 }
171
172 // Return state of operation.
173 return bReturn;
174}
175
177 sal_Int32 nHandle, const Any& aValue )
178{
179 SolarMutexGuard aGuard;
180
181 // Search for right handle ... and try to set property value.
182 switch( nHandle )
183 {
184 case HANDLE_COMMANDURL:
185 aValue >>= m_aCommandURL;
186 break;
187
188 case HANDLE_HELPURL:
189 aValue >>= m_aHelpURL;
190 break;
191
192 case HANDLE_IMAGE:
193 aValue >>= m_xBitmap;
194 break;
195
196 case HANDLE_SUBCONTAINER:
197 aValue >>= m_xActionTriggerContainer;
198 break;
199
200 case HANDLE_TEXT:
201 aValue >>= m_aText;
202 break;
203 }
204}
205
207 Any& aValue, sal_Int32 nHandle ) const
208{
209 SolarMutexGuard aGuard;
210
211 // Search for right handle ... and try to get property value.
212 switch( nHandle )
213 {
214 case HANDLE_COMMANDURL:
215 aValue <<= m_aCommandURL;
216 break;
217
218 case HANDLE_HELPURL:
219 aValue <<= m_aHelpURL;
220 break;
221
222 case HANDLE_IMAGE:
223 aValue <<= m_xBitmap;
224 break;
225
226 case HANDLE_SUBCONTAINER:
227 aValue <<= m_xActionTriggerContainer;
228 break;
229
230 case HANDLE_TEXT:
231 aValue <<= m_aText;
232 break;
233 }
234}
235
237{
238 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
239 // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
240 // "true" say: Table is sorted by name.
241 static OPropertyArrayHelper ourInfoHelper( impl_getStaticPropertyDescriptor(), true );
242
243 return ourInfoHelper;
244}
245
247{
248 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
249 // (Use method "getInfoHelper()".)
251
252 return xInfo;
253}
254
256{
257 return
258 {
259 Property( "CommandURL" , HANDLE_COMMANDURL , cppu::UnoType<OUString>::get(), PropertyAttribute::TRANSIENT ),
260 Property( "HelpURL" , HANDLE_HELPURL , cppu::UnoType<OUString>::get(), PropertyAttribute::TRANSIENT ),
261 Property( "Image" , HANDLE_IMAGE , cppu::UnoType<XBitmap>::get(), PropertyAttribute::TRANSIENT ),
262 Property( "SubContainer" , HANDLE_SUBCONTAINER , cppu::UnoType<OUString>::get(), PropertyAttribute::TRANSIENT ),
263 Property( "Text" , HANDLE_TEXT , cppu::UnoType<XInterface>::get(), PropertyAttribute::TRANSIENT )
264 };
265}
266
268 const OUString& sCurrentValue ,
269 const Any& aNewValue ,
270 Any& aOldValue ,
271 Any& aConvertedValue )
272{
273 // Set default return value if method failed.
274 bool bReturn = false;
275 // Get new value from any.
276 // IllegalArgumentException() can be thrown!
277 OUString sValue;
278 convertPropertyValue( sValue, aNewValue );
279
280 // If value change ...
281 if( sValue != sCurrentValue )
282 {
283 // ... set information of change.
284 aOldValue <<= sCurrentValue;
285 aConvertedValue <<= sValue;
286 // Return OK - "value will be change ..."
287 bReturn = true;
288 }
289 else
290 {
291 // ... clear information of return parameter!
292 aOldValue.clear ();
293 aConvertedValue.clear ();
294 // Return NOTHING - "value will not be change ..."
295 bReturn = false;
296 }
297
298 return bReturn;
299}
300
302 const Reference< XBitmap >& aCurrentValue ,
303 const Any& aNewValue ,
304 Any& aOldValue ,
305 Any& aConvertedValue )
306{
307 // Set default return value if method failed.
308 bool bReturn = false;
309 // Get new value from any.
310 // IllegalArgumentException() can be thrown!
312 convertPropertyValue( aValue, aNewValue );
313
314 // If value change ...
315 if( aValue != aCurrentValue )
316 {
317 // ... set information of change.
318 aOldValue <<= aCurrentValue;
319 aConvertedValue <<= aValue;
320 // Return OK - "value will be change ..."
321 bReturn = true;
322 }
323 else
324 {
325 // ... clear information of return parameter!
326 aOldValue.clear ();
327 aConvertedValue.clear ();
328 // Return NOTHING - "value will not be change ..."
329 bReturn = false;
330 }
331
332 return bReturn;
333}
334
336 const Reference< XInterface >& aCurrentValue ,
337 const Any& aNewValue ,
338 Any& aOldValue ,
339 Any& aConvertedValue )
340{
341 // Set default return value if method failed.
342 bool bReturn = false;
343 // Get new value from any.
344 // IllegalArgumentException() can be thrown!
346 convertPropertyValue( aValue, aNewValue );
347
348 // If value change ...
349 if( aValue != aCurrentValue )
350 {
351 // ... set information of change.
352 aOldValue <<= aCurrentValue;
353 aConvertedValue <<= aValue;
354 // Return OK - "value will be change ..."
355 bReturn = true;
356 }
357 else
358 {
359 // ... clear information of return parameter!
360 aOldValue.clear ();
361 aConvertedValue.clear ();
362 // Return NOTHING - "value will not be change ..."
363 bReturn = false;
364 }
365
366 return bReturn;
367}
368
369}
370
371/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGER
constexpr OUStringLiteral IMPLEMENTATIONNAME_ACTIONTRIGGER
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &aConvertedValue, css::uno::Any &aOldValue, sal_Int32 nHandle, const css::uno::Any &aValue) override
css::uno::Reference< css::uno::XInterface > m_xActionTriggerContainer
virtual void SAL_CALL acquire() noexcept override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
bool impl_tryToChangeProperty(const OUString &aCurrentValue, const css::uno::Any &aNewValue, css::uno::Any &aOldValue, css::uno::Any &aConvertedValue)
virtual void SAL_CALL release() noexcept override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &aValue, sal_Int32 nHandle) const override
css::uno::Reference< css::awt::XBitmap > m_xBitmap
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &aValue) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual OUString SAL_CALL getImplementationName() override
#define PROPERTYCOUNT
uno_Any a
Type
void SAL_CALL convertPropertyValue(target &value, const css::uno::Any &a)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 nHandle
unsigned char sal_Bool
std::mutex m_aMutex