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 <classes/actiontriggerpropertyset.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <cppuhelper/proptypehlp.hxx>
23 #include <cppuhelper/queryinterface.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <cppuhelper/typeprovider.hxx>
26 #include <vcl/svapp.hxx>
29 using namespace com::sun::star::uno
;
30 using namespace com::sun::star::beans
;
31 using namespace com::sun::star::lang
;
32 using namespace com::sun::star::awt
;
34 //struct SAL_DLLPUBLIC_IMPORT ::cppu::OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper, OMultiTypeInterfaceContainerHelper::keyType >;
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!
58 ActionTriggerPropertySet::ActionTriggerPropertySet()
59 : OBroadcastHelper ( m_aMutex
)
60 , OPropertySetHelper ( *static_cast< OBroadcastHelper
* >(this) )
64 ActionTriggerPropertySet::~ActionTriggerPropertySet()
69 Any SAL_CALL
ActionTriggerPropertySet::queryInterface( const Type
& aType
)
71 Any a
= ::cppu::queryInterface(
73 static_cast< XServiceInfo
* >(this),
74 static_cast< XTypeProvider
* >(this));
80 a
= OPropertySetHelper::queryInterface( aType
);
86 return OWeakObject::queryInterface( aType
);
89 void SAL_CALL
ActionTriggerPropertySet::acquire() noexcept
91 OWeakObject::acquire();
94 void SAL_CALL
ActionTriggerPropertySet::release() noexcept
96 OWeakObject::release();
100 OUString SAL_CALL
ActionTriggerPropertySet::getImplementationName()
102 return IMPLEMENTATIONNAME_ACTIONTRIGGER
;
105 sal_Bool SAL_CALL
ActionTriggerPropertySet::supportsService( const OUString
& ServiceName
)
107 return cppu::supportsService(this, ServiceName
);
110 Sequence
< OUString
> SAL_CALL
ActionTriggerPropertySet::getSupportedServiceNames()
112 Sequence
<OUString
> seqServiceNames
{ SERVICENAME_ACTIONTRIGGER
};
113 return seqServiceNames
;
117 Sequence
< Type
> SAL_CALL
ActionTriggerPropertySet::getTypes()
119 // Create a static typecollection ...
120 static ::cppu::OTypeCollection
ourTypeCollection(
121 cppu::UnoType
<XPropertySet
>::get(),
122 cppu::UnoType
<XFastPropertySet
>::get(),
123 cppu::UnoType
<XMultiPropertySet
>::get(),
124 cppu::UnoType
<XServiceInfo
>::get(),
125 cppu::UnoType
<XTypeProvider
>::get());
128 return ourTypeCollection
.getTypes();
131 Sequence
< sal_Int8
> SAL_CALL
ActionTriggerPropertySet::getImplementationId()
133 return css::uno::Sequence
<sal_Int8
>();
136 sal_Bool SAL_CALL
ActionTriggerPropertySet::convertFastPropertyValue(
137 Any
& aConvertedValue
,
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;
151 case HANDLE_COMMANDURL
:
152 bReturn
= impl_tryToChangeProperty( m_aCommandURL
, aValue
, aOldValue
, aConvertedValue
);
156 bReturn
= impl_tryToChangeProperty( m_aHelpURL
, aValue
, aOldValue
, aConvertedValue
);
160 bReturn
= impl_tryToChangeProperty( m_xBitmap
, aValue
, aOldValue
, aConvertedValue
);
163 case HANDLE_SUBCONTAINER
:
164 bReturn
= impl_tryToChangeProperty( m_xActionTriggerContainer
, aValue
, aOldValue
, aConvertedValue
);
168 bReturn
= impl_tryToChangeProperty( m_aText
, aValue
, aOldValue
, aConvertedValue
);
172 // Return state of operation.
176 void SAL_CALL
ActionTriggerPropertySet::setFastPropertyValue_NoBroadcast(
177 sal_Int32 nHandle
, const Any
& aValue
)
179 SolarMutexGuard aGuard
;
181 // Search for right handle ... and try to set property value.
184 case HANDLE_COMMANDURL
:
185 aValue
>>= m_aCommandURL
;
189 aValue
>>= m_aHelpURL
;
193 aValue
>>= m_xBitmap
;
196 case HANDLE_SUBCONTAINER
:
197 aValue
>>= m_xActionTriggerContainer
;
206 void SAL_CALL
ActionTriggerPropertySet::getFastPropertyValue(
207 Any
& aValue
, sal_Int32 nHandle
) const
209 SolarMutexGuard aGuard
;
211 // Search for right handle ... and try to get property value.
214 case HANDLE_COMMANDURL
:
215 aValue
<<= m_aCommandURL
;
219 aValue
<<= m_aHelpURL
;
223 aValue
<<= m_xBitmap
;
226 case HANDLE_SUBCONTAINER
:
227 aValue
<<= m_xActionTriggerContainer
;
236 ::cppu::IPropertyArrayHelper
& SAL_CALL
ActionTriggerPropertySet::getInfoHelper()
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 );
243 return ourInfoHelper
;
246 Reference
< XPropertySetInfo
> SAL_CALL
ActionTriggerPropertySet::getPropertySetInfo()
248 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
249 // (Use method "getInfoHelper()".)
250 static Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
255 Sequence
< Property
> ActionTriggerPropertySet::impl_getStaticPropertyDescriptor()
259 Property( u
"CommandURL"_ustr
, HANDLE_COMMANDURL
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::TRANSIENT
),
260 Property( u
"HelpURL"_ustr
, HANDLE_HELPURL
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::TRANSIENT
),
261 Property( u
"Image"_ustr
, HANDLE_IMAGE
, cppu::UnoType
<XBitmap
>::get(), PropertyAttribute::TRANSIENT
),
262 Property( u
"SubContainer"_ustr
, HANDLE_SUBCONTAINER
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::TRANSIENT
),
263 Property( u
"Text"_ustr
, HANDLE_TEXT
, cppu::UnoType
<XInterface
>::get(), PropertyAttribute::TRANSIENT
)
268 bool ActionTriggerPropertySet::impl_tryToChangeProperty(
269 const OUString
& sCurrentValue
,
270 const Any
& aNewValue
,
272 Any
& aConvertedValue
)
274 // Set default return value if method failed.
275 bool bReturn
= false;
276 // Get new value from any.
277 // IllegalArgumentException() can be thrown!
279 convertPropertyValue( sValue
, aNewValue
);
281 // If value change ...
282 if( sValue
!= sCurrentValue
)
284 // ... set information of change.
285 aOldValue
<<= sCurrentValue
;
286 aConvertedValue
<<= sValue
;
287 // Return OK - "value will be change ..."
292 // ... clear information of return parameter!
294 aConvertedValue
.clear ();
295 // Return NOTHING - "value will not be change ..."
303 bool ActionTriggerPropertySet::impl_tryToChangeProperty(
304 const Reference
< XBitmap
>& aCurrentValue
,
305 const Any
& aNewValue
,
307 Any
& aConvertedValue
)
309 // Set default return value if method failed.
310 bool bReturn
= false;
311 // Get new value from any.
312 // IllegalArgumentException() can be thrown!
313 Reference
< XBitmap
> aValue
;
314 convertPropertyValue( aValue
, aNewValue
);
316 // If value change ...
317 if( aValue
!= aCurrentValue
)
319 // ... set information of change.
320 aOldValue
<<= aCurrentValue
;
321 aConvertedValue
<<= aValue
;
322 // Return OK - "value will be change ..."
327 // ... clear information of return parameter!
329 aConvertedValue
.clear ();
330 // Return NOTHING - "value will not be change ..."
338 bool ActionTriggerPropertySet::impl_tryToChangeProperty(
339 const Reference
< XInterface
>& aCurrentValue
,
340 const Any
& aNewValue
,
342 Any
& aConvertedValue
)
344 // Set default return value if method failed.
345 bool bReturn
= false;
346 // Get new value from any.
347 // IllegalArgumentException() can be thrown!
348 Reference
< XInterface
> aValue
;
349 convertPropertyValue( aValue
, aNewValue
);
351 // If value change ...
352 if( aValue
!= aCurrentValue
)
354 // ... set information of change.
355 aOldValue
<<= aCurrentValue
;
356 aConvertedValue
<<= aValue
;
357 // Return OK - "value will be change ..."
362 // ... clear information of return parameter!
364 aConvertedValue
.clear ();
365 // Return NOTHING - "value will not be change ..."
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */