1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
31 #include <classes/actiontriggerseparatorpropertyset.hxx>
32 #include <com/sun/star/beans/PropertyAttribute.hpp>
33 #include <cppuhelper/proptypehlp.hxx>
34 #include <cppuhelper/typeprovider.hxx>
35 #include <vcl/svapp.hxx>
39 using namespace com::sun::star::uno
;
40 using namespace com::sun::star::beans
;
41 using namespace com::sun::star::lang
;
42 using namespace com::sun::star::awt
;
44 // Handles for properties
45 // (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
46 // We use an enum to define these handles, to use all numbers from 0 to nn and
47 // if you add someone, you don't must control this!
48 // But don't forget to change values of follow defines, if you do something with this enum!
58 ActionTriggerSeparatorPropertySet::ActionTriggerSeparatorPropertySet( const Reference
< XMultiServiceFactory
>& /*ServiceManager*/ )
59 : ThreadHelpBase ( &Application::GetSolarMutex() )
60 , OBroadcastHelper ( m_aLock
.getShareableOslMutex() )
61 , OPropertySetHelper ( *SAL_STATIC_CAST( OBroadcastHelper
*, this ) )
63 , m_nSeparatorType( 0 )
67 ActionTriggerSeparatorPropertySet::~ActionTriggerSeparatorPropertySet()
72 Any SAL_CALL
ActionTriggerSeparatorPropertySet::queryInterface( const Type
& aType
)
73 throw ( RuntimeException
)
75 Any a
= ::cppu::queryInterface(
77 SAL_STATIC_CAST( XServiceInfo
*, this ));
83 a
= OPropertySetHelper::queryInterface( aType
);
89 return OWeakObject::queryInterface( aType
);
92 void ActionTriggerSeparatorPropertySet::acquire() throw()
94 OWeakObject::acquire();
97 void ActionTriggerSeparatorPropertySet::release() throw()
99 OWeakObject::release();
103 ::rtl::OUString SAL_CALL
ActionTriggerSeparatorPropertySet::getImplementationName()
104 throw ( RuntimeException
)
106 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR
));
109 sal_Bool SAL_CALL
ActionTriggerSeparatorPropertySet::supportsService( const ::rtl::OUString
& ServiceName
)
110 throw ( RuntimeException
)
112 if ( ServiceName
.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR
))
118 Sequence
< ::rtl::OUString
> SAL_CALL
ActionTriggerSeparatorPropertySet::getSupportedServiceNames()
119 throw ( RuntimeException
)
121 Sequence
< ::rtl::OUString
> seqServiceNames( 1 );
122 seqServiceNames
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR
));
123 return seqServiceNames
;
127 Sequence
< Type
> SAL_CALL
ActionTriggerSeparatorPropertySet::getTypes() throw ( RuntimeException
)
129 // Optimize this method !
130 // We initialize a static variable only one time. And we don't must use a mutex at every call!
131 // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
132 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
134 if ( pTypeCollection
== NULL
)
136 // Ready for multithreading; get global mutex for first call of this method only! see before
137 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
139 // Control these pointer again ... it can be, that another instance will be faster then these!
140 if ( pTypeCollection
== NULL
)
142 // Create a static typecollection ...
143 static ::cppu::OTypeCollection
aTypeCollection(
144 ::getCppuType(( const Reference
< XPropertySet
>*)NULL
) ,
145 ::getCppuType(( const Reference
< XFastPropertySet
>*)NULL
) ,
146 ::getCppuType(( const Reference
< XMultiPropertySet
>*)NULL
) ,
147 ::getCppuType(( const Reference
< XServiceInfo
>*)NULL
) ,
148 ::getCppuType(( const Reference
< XTypeProvider
>*)NULL
) ) ;
150 // ... and set his address to static pointer!
151 pTypeCollection
= &aTypeCollection
;
155 return pTypeCollection
->getTypes() ;
158 Sequence
< sal_Int8
> SAL_CALL
ActionTriggerSeparatorPropertySet::getImplementationId() throw ( RuntimeException
)
160 // Create one Id for all instances of this class.
161 // Use ethernet address to do this! (sal_True)
163 // Optimize this method
164 // We initialize a static variable only one time. And we don't must use a mutex at every call!
165 // For the first call; pID is NULL - for the second call pID is different from NULL!
166 static ::cppu::OImplementationId
* pID
= NULL
;
170 // Ready for multithreading; get global mutex for first call of this method only! see before
171 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
173 // Control these pointer again ... it can be, that another instance will be faster then these!
176 // Create a new static ID ...
177 static ::cppu::OImplementationId
aID( sal_False
) ;
178 // ... and set his address to static pointer!
183 return pID
->getImplementationId() ;
186 //---------------------------------------------------------------------------------------------------------
187 // OPropertySetHelper implementation
188 //---------------------------------------------------------------------------------------------------------
190 sal_Bool SAL_CALL
ActionTriggerSeparatorPropertySet::convertFastPropertyValue(
191 Any
& aConvertedValue
,
195 throw( IllegalArgumentException
)
197 // Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
198 // Return TRUE, if changed - else return FALSE.
199 // Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
200 // Initialize return value with FALSE !!!
201 // (Handle can be invalid)
202 sal_Bool bReturn
= sal_False
;
207 bReturn
= impl_tryToChangeProperty( m_nSeparatorType
, aValue
, aOldValue
, aConvertedValue
);
211 // Return state of operation.
216 void SAL_CALL
ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcast(
217 sal_Int32 nHandle
, const Any
& aValue
)
220 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
222 // Search for right handle ... and try to set property value.
226 aValue
>>= m_nSeparatorType
;
231 void SAL_CALL
ActionTriggerSeparatorPropertySet::getFastPropertyValue(
232 Any
& aValue
, sal_Int32 nHandle
) const
234 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
236 // Search for right handle ... and try to get property value.
240 aValue
<<= m_nSeparatorType
;
245 ::cppu::IPropertyArrayHelper
& SAL_CALL
ActionTriggerSeparatorPropertySet::getInfoHelper()
247 // Optimize this method !
248 // We initialize a static variable only one time. And we don't must use a mutex at every call!
249 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
250 static OPropertyArrayHelper
* pInfoHelper
= NULL
;
252 if( pInfoHelper
== NULL
)
254 // Ready for multithreading
255 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
256 // Control this pointer again, another instance can be faster then these!
257 if( pInfoHelper
== NULL
)
259 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
260 // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
261 // "sal_True" say: Table is sorted by name.
262 static OPropertyArrayHelper
aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True
);
263 pInfoHelper
= &aInfoHelper
;
267 return (*pInfoHelper
);
270 Reference
< XPropertySetInfo
> SAL_CALL
ActionTriggerSeparatorPropertySet::getPropertySetInfo()
271 throw ( RuntimeException
)
273 // Optimize this method !
274 // We initialize a static variable only one time. And we don't must use a mutex at every call!
275 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
276 static Reference
< XPropertySetInfo
>* pInfo
= NULL
;
280 // Ready for multithreading
281 ::osl::MutexGuard
aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
282 // Control this pointer again, another instance can be faster then these!
285 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
286 // (Use method "getInfoHelper()".)
287 static Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
295 const Sequence
< Property
> ActionTriggerSeparatorPropertySet::impl_getStaticPropertyDescriptor()
297 static const Property pActionTriggerPropertys
[] =
299 Property( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SeparatorType" )), HANDLE_TYPE
, ::getCppuType((sal_Int16
*)0), PropertyAttribute::TRANSIENT
)
302 // Use it to initialize sequence!
303 static const Sequence
< Property
> seqActionTriggerPropertyDescriptor( pActionTriggerPropertys
, PROPERTYCOUNT
);
305 // Return static "PropertyDescriptor"
306 return seqActionTriggerPropertyDescriptor
;
310 //******************************************************************************************************************************
312 //******************************************************************************************************************************
313 sal_Bool
ActionTriggerSeparatorPropertySet::impl_tryToChangeProperty(
314 sal_Int16 aCurrentValue
,
315 const Any
& aNewValue
,
317 Any
& aConvertedValue
)
318 throw( IllegalArgumentException
)
320 // Set default return value if method failed.
321 sal_Bool bReturn
= sal_False
;
322 // Get new value from any.
323 // IllegalArgumentException() can be thrown!
324 sal_Int16 aValue
= 0;
325 convertPropertyValue( aValue
, aNewValue
);
327 // If value change ...
328 if( aValue
!= aCurrentValue
)
330 // ... set information of change.
331 aOldValue
<<= aCurrentValue
;
332 aConvertedValue
<<= aValue
;
333 // Return OK - "value will be change ..."
338 // ... clear information of return parameter!
340 aConvertedValue
.clear () ;
341 // Return NOTHING - "value will not be change ..."