16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56d739b60SAndrew Rist  * distributed with this work for additional information
66d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
106d739b60SAndrew Rist  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
126d739b60SAndrew Rist  *
136d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist  * software distributed under the License is distributed on an
156d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
176d739b60SAndrew Rist  * specific language governing permissions and limitations
186d739b60SAndrew Rist  * under the License.
196d739b60SAndrew Rist  *
206d739b60SAndrew Rist  *************************************************************/
216d739b60SAndrew Rist 
226d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir #include <classes/actiontriggercontainer.hxx>
27cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <classes/actiontriggerpropertyset.hxx>
30cdf0e10cSrcweir #include <classes/actiontriggerseparatorpropertyset.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace cppu;
33cdf0e10cSrcweir using namespace com::sun::star::uno;
34cdf0e10cSrcweir using namespace com::sun::star::lang;
35cdf0e10cSrcweir using namespace com::sun::star::container;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace framework
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 
ActionTriggerContainer(const Reference<XMultiServiceFactory> & rServiceManager)40cdf0e10cSrcweir ActionTriggerContainer::ActionTriggerContainer( const Reference< XMultiServiceFactory >& rServiceManager ) :
41cdf0e10cSrcweir 	PropertySetContainer( rServiceManager )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
~ActionTriggerContainer()46cdf0e10cSrcweir ActionTriggerContainer::~ActionTriggerContainer()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // XInterface
queryInterface(const Type & aType)51cdf0e10cSrcweir Any SAL_CALL ActionTriggerContainer::queryInterface( const Type& aType )
52cdf0e10cSrcweir throw ( RuntimeException )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	Any a = ::cppu::queryInterface(
55cdf0e10cSrcweir 				aType ,
56cdf0e10cSrcweir 				SAL_STATIC_CAST( XMultiServiceFactory*, this ),
57*5b6a8715SAriel Constenla-Haile 				SAL_STATIC_CAST( XServiceInfo* ,  this ),
58*5b6a8715SAriel Constenla-Haile 				SAL_STATIC_CAST( XTypeProvider* ,  this ));
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	if( a.hasValue() )
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir 		return a;
63cdf0e10cSrcweir 	}
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	return PropertySetContainer::queryInterface( aType );
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
acquire()68cdf0e10cSrcweir void ActionTriggerContainer::acquire() throw()
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	PropertySetContainer::acquire();
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
release()73cdf0e10cSrcweir void ActionTriggerContainer::release() throw()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	PropertySetContainer::release();
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // XMultiServiceFactory
createInstance(const::rtl::OUString & aServiceSpecifier)80cdf0e10cSrcweir Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstance( const ::rtl::OUString& aServiceSpecifier )
81cdf0e10cSrcweir throw ( ::com::sun::star::uno::Exception, RuntimeException)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGER ))
84cdf0e10cSrcweir 		return (OWeakObject *)( new ActionTriggerPropertySet( m_xServiceManager ));
85cdf0e10cSrcweir 	else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
86cdf0e10cSrcweir 		return (OWeakObject *)( new ActionTriggerContainer( m_xServiceManager ));
87cdf0e10cSrcweir 	else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR ))
88cdf0e10cSrcweir 		return (OWeakObject *)( new ActionTriggerSeparatorPropertySet( m_xServiceManager ));
89cdf0e10cSrcweir 	else
90cdf0e10cSrcweir 		throw com::sun::star::uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown service specifier!" )), (OWeakObject *)this );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
createInstanceWithArguments(const::rtl::OUString & ServiceSpecifier,const Sequence<Any> &)94cdf0e10cSrcweir Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/ )
95cdf0e10cSrcweir throw ( Exception, RuntimeException)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	return createInstance( ServiceSpecifier );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
getAvailableServiceNames()101cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getAvailableServiceNames()
102cdf0e10cSrcweir throw ( RuntimeException )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aSeq( 3 );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGER ));
107cdf0e10cSrcweir 	aSeq[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
108cdf0e10cSrcweir 	aSeq[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR ));
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	return aSeq;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir // XServiceInfo
getImplementationName()114cdf0e10cSrcweir ::rtl::OUString SAL_CALL ActionTriggerContainer::getImplementationName()
115cdf0e10cSrcweir throw ( RuntimeException )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERCONTAINER ));
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
supportsService(const::rtl::OUString & ServiceName)120cdf0e10cSrcweir sal_Bool SAL_CALL ActionTriggerContainer::supportsService( const ::rtl::OUString& ServiceName )
121cdf0e10cSrcweir throw ( RuntimeException )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	if ( ServiceName.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
124cdf0e10cSrcweir 		return sal_True;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	return sal_False;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
getSupportedServiceNames()129cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getSupportedServiceNames()
130cdf0e10cSrcweir throw ( RuntimeException )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     Sequence< ::rtl::OUString > seqServiceNames( 1 );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	seqServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
135cdf0e10cSrcweir 	return seqServiceNames;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // XTypeProvider
getTypes()139cdf0e10cSrcweir Sequence< Type > SAL_CALL ActionTriggerContainer::getTypes() throw ( RuntimeException )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	// Optimize this method !
142cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
143cdf0e10cSrcweir 	// For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
144cdf0e10cSrcweir 	static ::cppu::OTypeCollection* pTypeCollection = NULL ;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	if ( pTypeCollection == NULL )
147cdf0e10cSrcweir 	{
148cdf0e10cSrcweir 		// Ready for multithreading; get global mutex for first call of this method only! see before
149cdf0e10cSrcweir 		osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		// Control these pointer again ... it can be, that another instance will be faster then these!
152cdf0e10cSrcweir 		if ( pTypeCollection == NULL )
153cdf0e10cSrcweir 		{
154cdf0e10cSrcweir 			// Create a static typecollection ...
155cdf0e10cSrcweir 			static ::cppu::OTypeCollection aTypeCollection(
156cdf0e10cSrcweir 						::getCppuType(( const Reference< XMultiServiceFactory	>*)NULL ) ,
157cdf0e10cSrcweir 						::getCppuType(( const Reference< XIndexContainer		>*)NULL ) ,
158cdf0e10cSrcweir 						::getCppuType(( const Reference< XServiceInfo			>*)NULL ) ,
159cdf0e10cSrcweir 						::getCppuType(( const Reference< XTypeProvider			>*)NULL ) ) ;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 			// ... and set his address to static pointer!
162cdf0e10cSrcweir 			pTypeCollection = &aTypeCollection ;
163cdf0e10cSrcweir 		}
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	return pTypeCollection->getTypes() ;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
getImplementationId()169cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ActionTriggerContainer::getImplementationId() throw ( RuntimeException )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	// Create one Id for all instances of this class.
172cdf0e10cSrcweir 	// Use ethernet address to do this! (sal_True)
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	// Optimize this method
175cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
176cdf0e10cSrcweir 	// For the first call; pID is NULL - for the second call pID is different from NULL!
177cdf0e10cSrcweir 	static ::cppu::OImplementationId* pID = NULL ;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	if ( pID == NULL )
180cdf0e10cSrcweir 	{
181cdf0e10cSrcweir 		// Ready for multithreading; get global mutex for first call of this method only! see before
182cdf0e10cSrcweir 		osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 		// Control these pointer again ... it can be, that another instance will be faster then these!
185cdf0e10cSrcweir 		if ( pID == NULL )
186cdf0e10cSrcweir 		{
187cdf0e10cSrcweir 			// Create a new static ID ...
188cdf0e10cSrcweir 			static ::cppu::OImplementationId aID( sal_False ) ;
189cdf0e10cSrcweir 			// ... and set his address to static pointer!
190cdf0e10cSrcweir 			pID = &aID ;
191cdf0e10cSrcweir 		}
192cdf0e10cSrcweir 	}
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	return pID->getImplementationId() ;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199