1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: actiontriggerseparatorpropertyset.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #include <classes/actiontriggerseparatorpropertyset.hxx>
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <cppuhelper/proptypehlp.hxx>
37 #include <cppuhelper/typeprovider.hxx>
38 #include <vcl/svapp.hxx>
42 using namespace com::sun::star::uno
;
43 using namespace com::sun::star::beans
;
44 using namespace com::sun::star::lang
;
45 using namespace com::sun::star::awt
;
47 // Handles for properties
48 // (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
49 // We use an enum to define these handles, to use all numbers from 0 to nn and
50 // if you add someone, you don't must control this!
51 // But don't forget to change values of follow defines, if you do something with this enum!
61 ActionTriggerSeparatorPropertySet::ActionTriggerSeparatorPropertySet( const Reference
< XMultiServiceFactory
>& /*ServiceManager*/ )
62 : ThreadHelpBase ( &Application::GetSolarMutex() )
63 , OBroadcastHelper ( m_aLock
.getShareableOslMutex() )
64 , OPropertySetHelper ( *SAL_STATIC_CAST( OBroadcastHelper
*, this ) )
66 , m_nSeparatorType( 0 )
70 ActionTriggerSeparatorPropertySet::~ActionTriggerSeparatorPropertySet()
75 Any SAL_CALL
ActionTriggerSeparatorPropertySet::queryInterface( const Type
& aType
)
76 throw ( RuntimeException
)
78 Any a
= ::cppu::queryInterface(
80 SAL_STATIC_CAST( XServiceInfo
*, this ));
86 a
= OPropertySetHelper::queryInterface( aType
);
92 return OWeakObject::queryInterface( aType
);
95 void ActionTriggerSeparatorPropertySet::acquire() throw()
97 OWeakObject::acquire();
100 void ActionTriggerSeparatorPropertySet::release() throw()
102 OWeakObject::release();
106 ::rtl::OUString SAL_CALL
ActionTriggerSeparatorPropertySet::getImplementationName()
107 throw ( RuntimeException
)
109 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR
));
112 sal_Bool SAL_CALL
ActionTriggerSeparatorPropertySet::supportsService( const ::rtl::OUString
& ServiceName
)
113 throw ( RuntimeException
)
115 if ( ServiceName
.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR
))
121 Sequence
< ::rtl::OUString
> SAL_CALL
ActionTriggerSeparatorPropertySet::getSupportedServiceNames()
122 throw ( RuntimeException
)
124 Sequence
< ::rtl::OUString
> seqServiceNames( 1 );
125 seqServiceNames
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR
));
126 return seqServiceNames
;
130 Sequence
< Type
> SAL_CALL
ActionTriggerSeparatorPropertySet::getTypes() throw ( RuntimeException
)
132 // Optimize this method !
133 // We initialize a static variable only one time. And we don't must use a mutex at every call!
134 // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
135 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
137 if ( pTypeCollection
== NULL
)
139 // Ready for multithreading; get global mutex for first call of this method only! see before
140 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
142 // Control these pointer again ... it can be, that another instance will be faster then these!
143 if ( pTypeCollection
== NULL
)
145 // Create a static typecollection ...
146 static ::cppu::OTypeCollection
aTypeCollection(
147 ::getCppuType(( const Reference
< XPropertySet
>*)NULL
) ,
148 ::getCppuType(( const Reference
< XFastPropertySet
>*)NULL
) ,
149 ::getCppuType(( const Reference
< XMultiPropertySet
>*)NULL
) ,
150 ::getCppuType(( const Reference
< XServiceInfo
>*)NULL
) ,
151 ::getCppuType(( const Reference
< XTypeProvider
>*)NULL
) ) ;
153 // ... and set his address to static pointer!
154 pTypeCollection
= &aTypeCollection
;
158 return pTypeCollection
->getTypes() ;
161 Sequence
< sal_Int8
> SAL_CALL
ActionTriggerSeparatorPropertySet::getImplementationId() throw ( RuntimeException
)
163 // Create one Id for all instances of this class.
164 // Use ethernet address to do this! (sal_True)
166 // Optimize this method
167 // We initialize a static variable only one time. And we don't must use a mutex at every call!
168 // For the first call; pID is NULL - for the second call pID is different from NULL!
169 static ::cppu::OImplementationId
* pID
= NULL
;
173 // Ready for multithreading; get global mutex for first call of this method only! see before
174 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
176 // Control these pointer again ... it can be, that another instance will be faster then these!
179 // Create a new static ID ...
180 static ::cppu::OImplementationId
aID( sal_False
) ;
181 // ... and set his address to static pointer!
186 return pID
->getImplementationId() ;
189 //---------------------------------------------------------------------------------------------------------
190 // OPropertySetHelper implementation
191 //---------------------------------------------------------------------------------------------------------
193 sal_Bool SAL_CALL
ActionTriggerSeparatorPropertySet::convertFastPropertyValue(
194 Any
& aConvertedValue
,
198 throw( IllegalArgumentException
)
200 // Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
201 // Return TRUE, if changed - else return FALSE.
202 // Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
203 // Initialize return value with FALSE !!!
204 // (Handle can be invalid)
205 sal_Bool bReturn
= sal_False
;
210 bReturn
= impl_tryToChangeProperty( m_nSeparatorType
, aValue
, aOldValue
, aConvertedValue
);
214 // Return state of operation.
219 void SAL_CALL
ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcast(
220 sal_Int32 nHandle
, const Any
& aValue
)
223 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
225 // Search for right handle ... and try to set property value.
229 aValue
>>= m_nSeparatorType
;
234 void SAL_CALL
ActionTriggerSeparatorPropertySet::getFastPropertyValue(
235 Any
& aValue
, sal_Int32 nHandle
) const
237 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
239 // Search for right handle ... and try to get property value.
243 aValue
<<= m_nSeparatorType
;
248 ::cppu::IPropertyArrayHelper
& SAL_CALL
ActionTriggerSeparatorPropertySet::getInfoHelper()
250 // Optimize this method !
251 // We initialize a static variable only one time. And we don't must use a mutex at every call!
252 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
253 static OPropertyArrayHelper
* pInfoHelper
= NULL
;
255 if( pInfoHelper
== NULL
)
257 // Ready for multithreading
258 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
259 // Control this pointer again, another instance can be faster then these!
260 if( pInfoHelper
== NULL
)
262 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
263 // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
264 // "sal_True" say: Table is sorted by name.
265 static OPropertyArrayHelper
aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True
);
266 pInfoHelper
= &aInfoHelper
;
270 return (*pInfoHelper
);
273 Reference
< XPropertySetInfo
> SAL_CALL
ActionTriggerSeparatorPropertySet::getPropertySetInfo()
274 throw ( RuntimeException
)
276 // Optimize this method !
277 // We initialize a static variable only one time. And we don't must use a mutex at every call!
278 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
279 static Reference
< XPropertySetInfo
>* pInfo
= NULL
;
283 // Ready for multithreading
284 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
285 // Control this pointer again, another instance can be faster then these!
288 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
289 // (Use method "getInfoHelper()".)
290 static Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
298 const Sequence
< Property
> ActionTriggerSeparatorPropertySet::impl_getStaticPropertyDescriptor()
300 static const Property pActionTriggerPropertys
[] =
302 Property( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SeparatorType" )), HANDLE_TYPE
, ::getCppuType((sal_Int16
*)0), PropertyAttribute::TRANSIENT
)
305 // Use it to initialize sequence!
306 static const Sequence
< Property
> seqActionTriggerPropertyDescriptor( pActionTriggerPropertys
, PROPERTYCOUNT
);
308 // Return static "PropertyDescriptor"
309 return seqActionTriggerPropertyDescriptor
;
313 //******************************************************************************************************************************
315 //******************************************************************************************************************************
316 sal_Bool
ActionTriggerSeparatorPropertySet::impl_tryToChangeProperty(
317 sal_Int16 aCurrentValue
,
318 const Any
& aNewValue
,
320 Any
& aConvertedValue
)
321 throw( IllegalArgumentException
)
323 // Set default return value if method failed.
324 sal_Bool bReturn
= sal_False
;
325 // Get new value from any.
326 // IllegalArgumentException() can be thrown!
327 sal_Int16 aValue
= 0;
328 convertPropertyValue( aValue
, aNewValue
);
330 // If value change ...
331 if( aValue
!= aCurrentValue
)
333 // ... set information of change.
334 aOldValue
<<= aCurrentValue
;
335 aConvertedValue
<<= aValue
;
336 // Return OK - "value will be change ..."
341 // ... clear information of return parameter!
343 aConvertedValue
.clear () ;
344 // Return NOTHING - "value will not be change ..."