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/actiontriggerseparatorpropertyset.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <cppuhelper/proptypehlp.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <cppuhelper/queryinterface.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 // Handles for properties
35 // (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
36 // We use an enum to define these handles, to use all numbers from 0 to nn and
37 // if you add someone, you don't must control this!
38 // But don't forget to change values of follow defines, if you do something with this enum!
48 ActionTriggerSeparatorPropertySet::ActionTriggerSeparatorPropertySet()
49 : OBroadcastHelper ( m_aMutex
)
50 , OPropertySetHelper ( *(static_cast< OBroadcastHelper
* >(this)) )
52 , m_nSeparatorType( 0 )
56 ActionTriggerSeparatorPropertySet::~ActionTriggerSeparatorPropertySet()
61 Any SAL_CALL
ActionTriggerSeparatorPropertySet::queryInterface( const Type
& aType
)
62 throw ( RuntimeException
, std::exception
)
64 Any a
= ::cppu::queryInterface(
66 (static_cast< XServiceInfo
* >(this)),
67 (static_cast< XTypeProvider
* >(this)));
73 a
= OPropertySetHelper::queryInterface( aType
);
79 return OWeakObject::queryInterface( aType
);
82 void ActionTriggerSeparatorPropertySet::acquire() throw()
84 OWeakObject::acquire();
87 void ActionTriggerSeparatorPropertySet::release() throw()
89 OWeakObject::release();
93 OUString SAL_CALL
ActionTriggerSeparatorPropertySet::getImplementationName()
94 throw ( RuntimeException
, std::exception
)
96 return OUString( IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR
);
99 sal_Bool SAL_CALL
ActionTriggerSeparatorPropertySet::supportsService( const OUString
& ServiceName
)
100 throw ( RuntimeException
, std::exception
)
102 return cppu::supportsService(this, ServiceName
);
105 Sequence
< OUString
> SAL_CALL
ActionTriggerSeparatorPropertySet::getSupportedServiceNames()
106 throw ( RuntimeException
, std::exception
)
108 Sequence
< OUString
> seqServiceNames( 1 );
109 seqServiceNames
[0] = SERVICENAME_ACTIONTRIGGERSEPARATOR
;
110 return seqServiceNames
;
114 Sequence
< Type
> SAL_CALL
ActionTriggerSeparatorPropertySet::getTypes() throw ( RuntimeException
, std::exception
)
116 // Optimize this method !
117 // We initialize a static variable only one time. And we don't must use a mutex at every call!
118 // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
119 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
121 if ( pTypeCollection
== NULL
)
123 // Ready for multithreading; get global mutex for first call of this method only! see before
124 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() );
126 // Control these pointer again ... it can be, that another instance will be faster then these!
127 if ( pTypeCollection
== NULL
)
129 // Create a static typecollection ...
130 static ::cppu::OTypeCollection
aTypeCollection(
131 cppu::UnoType
<XPropertySet
>::get(),
132 cppu::UnoType
<XFastPropertySet
>::get(),
133 cppu::UnoType
<XMultiPropertySet
>::get(),
134 cppu::UnoType
<XServiceInfo
>::get(),
135 cppu::UnoType
<XTypeProvider
>::get());
137 // ... and set his address to static pointer!
138 pTypeCollection
= &aTypeCollection
;
142 return pTypeCollection
->getTypes();
145 Sequence
< sal_Int8
> SAL_CALL
ActionTriggerSeparatorPropertySet::getImplementationId() throw ( RuntimeException
, std::exception
)
147 return css::uno::Sequence
<sal_Int8
>();
150 sal_Bool SAL_CALL
ActionTriggerSeparatorPropertySet::convertFastPropertyValue(
151 Any
& aConvertedValue
,
155 throw( IllegalArgumentException
)
157 // Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
158 // Return sal_True, if changed - else return sal_False.
159 // Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
160 // Initialize return value with sal_False !!!
161 // (Handle can be invalid)
162 bool bReturn
= false;
167 bReturn
= impl_tryToChangeProperty( m_nSeparatorType
, aValue
, aOldValue
, aConvertedValue
);
171 // Return state of operation.
175 void SAL_CALL
ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcast(
176 sal_Int32 nHandle
, const Any
& aValue
)
177 throw( Exception
, std::exception
)
179 SolarMutexGuard aGuard
;
181 // Search for right handle ... and try to set property value.
185 aValue
>>= m_nSeparatorType
;
190 void SAL_CALL
ActionTriggerSeparatorPropertySet::getFastPropertyValue(
191 Any
& aValue
, sal_Int32 nHandle
) const
193 SolarMutexGuard aGuard
;
195 // Search for right handle ... and try to get property value.
199 aValue
<<= m_nSeparatorType
;
204 ::cppu::IPropertyArrayHelper
& SAL_CALL
ActionTriggerSeparatorPropertySet::getInfoHelper()
206 // Optimize this method !
207 // We initialize a static variable only one time. And we don't must use a mutex at every call!
208 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
209 static OPropertyArrayHelper
* pInfoHelper
= NULL
;
211 if( pInfoHelper
== NULL
)
213 SolarMutexGuard aGuard
;
214 // Control this pointer again, another instance can be faster then these!
215 if( pInfoHelper
== NULL
)
217 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
218 // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
219 // "sal_True" say: Table is sorted by name.
220 static OPropertyArrayHelper
aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True
);
221 pInfoHelper
= &aInfoHelper
;
225 return (*pInfoHelper
);
228 Reference
< XPropertySetInfo
> SAL_CALL
ActionTriggerSeparatorPropertySet::getPropertySetInfo()
229 throw ( RuntimeException
, std::exception
)
231 // Optimize this method !
232 // We initialize a static variable only one time. And we don't must use a mutex at every call!
233 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
234 static Reference
< XPropertySetInfo
>* pInfo
= NULL
;
238 SolarMutexGuard aGuard
;
239 // Control this pointer again, another instance can be faster then these!
242 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
243 // (Use method "getInfoHelper()".)
244 static Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
252 const Sequence
< Property
> ActionTriggerSeparatorPropertySet::impl_getStaticPropertyDescriptor()
254 const Property pActionTriggerPropertys
[] =
256 Property( OUString( "SeparatorType" ), HANDLE_TYPE
, cppu::UnoType
<sal_Int16
>::get(), PropertyAttribute::TRANSIENT
)
259 // Use it to initialize sequence!
260 const Sequence
< Property
> seqActionTriggerPropertyDescriptor( pActionTriggerPropertys
, PROPERTYCOUNT
);
262 // Return "PropertyDescriptor"
263 return seqActionTriggerPropertyDescriptor
;
266 bool ActionTriggerSeparatorPropertySet::impl_tryToChangeProperty(
267 sal_Int16 aCurrentValue
,
268 const Any
& aNewValue
,
270 Any
& aConvertedValue
)
271 throw( IllegalArgumentException
)
273 // Set default return value if method failed.
274 bool bReturn
= false;
275 // Get new value from any.
276 // IllegalArgumentException() can be thrown!
277 sal_Int16 aValue
= 0;
278 convertPropertyValue( aValue
, aNewValue
);
280 // If value change ...
281 if( aValue
!= aCurrentValue
)
283 // ... set information of change.
284 aOldValue
<<= aCurrentValue
;
285 aConvertedValue
<<= aValue
;
286 // Return OK - "value will be change ..."
291 // ... clear information of return parameter!
293 aConvertedValue
.clear ();
294 // Return NOTHING - "value will not be change ..."
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */