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( "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
)
267 bool ActionTriggerPropertySet::impl_tryToChangeProperty(
268 const OUString
& sCurrentValue
,
269 const Any
& aNewValue
,
271 Any
& aConvertedValue
)
273 // Set default return value if method failed.
274 bool bReturn
= false;
275 // Get new value from any.
276 // IllegalArgumentException() can be thrown!
278 convertPropertyValue( sValue
, aNewValue
);
280 // If value change ...
281 if( sValue
!= sCurrentValue
)
283 // ... set information of change.
284 aOldValue
<<= sCurrentValue
;
285 aConvertedValue
<<= sValue
;
286 // Return OK - "value will be change ..."
291 // ... clear information of return parameter!
293 aConvertedValue
.clear ();
294 // Return NOTHING - "value will not be change ..."
301 bool ActionTriggerPropertySet::impl_tryToChangeProperty(
302 const Reference
< XBitmap
>& aCurrentValue
,
303 const Any
& aNewValue
,
305 Any
& aConvertedValue
)
307 // Set default return value if method failed.
308 bool bReturn
= false;
309 // Get new value from any.
310 // IllegalArgumentException() can be thrown!
311 Reference
< XBitmap
> aValue
;
312 convertPropertyValue( aValue
, aNewValue
);
314 // If value change ...
315 if( aValue
!= aCurrentValue
)
317 // ... set information of change.
318 aOldValue
<<= aCurrentValue
;
319 aConvertedValue
<<= aValue
;
320 // Return OK - "value will be change ..."
325 // ... clear information of return parameter!
327 aConvertedValue
.clear ();
328 // Return NOTHING - "value will not be change ..."
335 bool ActionTriggerPropertySet::impl_tryToChangeProperty(
336 const Reference
< XInterface
>& aCurrentValue
,
337 const Any
& aNewValue
,
339 Any
& aConvertedValue
)
341 // Set default return value if method failed.
342 bool bReturn
= false;
343 // Get new value from any.
344 // IllegalArgumentException() can be thrown!
345 Reference
< XInterface
> aValue
;
346 convertPropertyValue( aValue
, aNewValue
);
348 // If value change ...
349 if( aValue
!= aCurrentValue
)
351 // ... set information of change.
352 aOldValue
<<= aCurrentValue
;
353 aConvertedValue
<<= aValue
;
354 // Return OK - "value will be change ..."
359 // ... clear information of return parameter!
361 aConvertedValue
.clear ();
362 // Return NOTHING - "value will not be change ..."
371 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */