1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir #include <classes/actiontriggercontainer.hxx>
31*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <classes/actiontriggerpropertyset.hxx>
34*cdf0e10cSrcweir #include <classes/actiontriggerseparatorpropertyset.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir using namespace cppu;
37*cdf0e10cSrcweir using namespace com::sun::star::uno;
38*cdf0e10cSrcweir using namespace com::sun::star::lang;
39*cdf0e10cSrcweir using namespace com::sun::star::container;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace framework
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir ActionTriggerContainer::ActionTriggerContainer( const Reference< XMultiServiceFactory >& rServiceManager ) :
45*cdf0e10cSrcweir 	PropertySetContainer( rServiceManager )
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir }
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir ActionTriggerContainer::~ActionTriggerContainer()
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir }
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir // XInterface
55*cdf0e10cSrcweir Any SAL_CALL ActionTriggerContainer::queryInterface( const Type& aType )
56*cdf0e10cSrcweir throw ( RuntimeException )
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir 	Any a = ::cppu::queryInterface(
59*cdf0e10cSrcweir 				aType ,
60*cdf0e10cSrcweir 				SAL_STATIC_CAST( XMultiServiceFactory*, this ),
61*cdf0e10cSrcweir 				SAL_STATIC_CAST( XServiceInfo* ,  this ));
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	if( a.hasValue() )
64*cdf0e10cSrcweir 	{
65*cdf0e10cSrcweir 		return a;
66*cdf0e10cSrcweir 	}
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 	return PropertySetContainer::queryInterface( aType );
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir void ActionTriggerContainer::acquire() throw()
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	PropertySetContainer::acquire();
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir void ActionTriggerContainer::release() throw()
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	PropertySetContainer::release();
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir // XMultiServiceFactory
83*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstance( const ::rtl::OUString& aServiceSpecifier )
84*cdf0e10cSrcweir throw ( ::com::sun::star::uno::Exception, RuntimeException)
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir 	if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGER ))
87*cdf0e10cSrcweir 		return (OWeakObject *)( new ActionTriggerPropertySet( m_xServiceManager ));
88*cdf0e10cSrcweir 	else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
89*cdf0e10cSrcweir 		return (OWeakObject *)( new ActionTriggerContainer( m_xServiceManager ));
90*cdf0e10cSrcweir 	else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR ))
91*cdf0e10cSrcweir 		return (OWeakObject *)( new ActionTriggerSeparatorPropertySet( m_xServiceManager ));
92*cdf0e10cSrcweir 	else
93*cdf0e10cSrcweir 		throw com::sun::star::uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown service specifier!" )), (OWeakObject *)this );
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/ )
98*cdf0e10cSrcweir throw ( Exception, RuntimeException)
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir 	return createInstance( ServiceSpecifier );
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getAvailableServiceNames()
105*cdf0e10cSrcweir throw ( RuntimeException )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aSeq( 3 );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGER ));
110*cdf0e10cSrcweir 	aSeq[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
111*cdf0e10cSrcweir 	aSeq[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR ));
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	return aSeq;
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir // XServiceInfo
117*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ActionTriggerContainer::getImplementationName()
118*cdf0e10cSrcweir throw ( RuntimeException )
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERCONTAINER ));
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir sal_Bool SAL_CALL ActionTriggerContainer::supportsService( const ::rtl::OUString& ServiceName )
124*cdf0e10cSrcweir throw ( RuntimeException )
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir 	if ( ServiceName.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
127*cdf0e10cSrcweir 		return sal_True;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	return sal_False;
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getSupportedServiceNames()
133*cdf0e10cSrcweir throw ( RuntimeException )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     Sequence< ::rtl::OUString > seqServiceNames( 1 );
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	seqServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
138*cdf0e10cSrcweir 	return seqServiceNames;
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir // XTypeProvider
142*cdf0e10cSrcweir Sequence< Type > SAL_CALL ActionTriggerContainer::getTypes() throw ( RuntimeException )
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	// Optimize this method !
145*cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
146*cdf0e10cSrcweir 	// For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
147*cdf0e10cSrcweir 	static ::cppu::OTypeCollection* pTypeCollection = NULL ;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	if ( pTypeCollection == NULL )
150*cdf0e10cSrcweir 	{
151*cdf0e10cSrcweir 		// Ready for multithreading; get global mutex for first call of this method only! see before
152*cdf0e10cSrcweir 		osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 		// Control these pointer again ... it can be, that another instance will be faster then these!
155*cdf0e10cSrcweir 		if ( pTypeCollection == NULL )
156*cdf0e10cSrcweir 		{
157*cdf0e10cSrcweir 			// Create a static typecollection ...
158*cdf0e10cSrcweir 			static ::cppu::OTypeCollection aTypeCollection(
159*cdf0e10cSrcweir 						::getCppuType(( const Reference< XMultiServiceFactory	>*)NULL ) ,
160*cdf0e10cSrcweir 						::getCppuType(( const Reference< XIndexContainer		>*)NULL ) ,
161*cdf0e10cSrcweir 						::getCppuType(( const Reference< XIndexAccess			>*)NULL ) ,
162*cdf0e10cSrcweir 						::getCppuType(( const Reference< XIndexReplace			>*)NULL ) ,
163*cdf0e10cSrcweir 						::getCppuType(( const Reference< XServiceInfo			>*)NULL ) ,
164*cdf0e10cSrcweir 						::getCppuType(( const Reference< XTypeProvider			>*)NULL ) ) ;
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 			// ... and set his address to static pointer!
167*cdf0e10cSrcweir 			pTypeCollection = &aTypeCollection ;
168*cdf0e10cSrcweir 		}
169*cdf0e10cSrcweir 	}
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	return pTypeCollection->getTypes() ;
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ActionTriggerContainer::getImplementationId() throw ( RuntimeException )
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir 	// Create one Id for all instances of this class.
177*cdf0e10cSrcweir 	// Use ethernet address to do this! (sal_True)
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 	// Optimize this method
180*cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
181*cdf0e10cSrcweir 	// For the first call; pID is NULL - for the second call pID is different from NULL!
182*cdf0e10cSrcweir 	static ::cppu::OImplementationId* pID = NULL ;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	if ( pID == NULL )
185*cdf0e10cSrcweir 	{
186*cdf0e10cSrcweir 		// Ready for multithreading; get global mutex for first call of this method only! see before
187*cdf0e10cSrcweir 		osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 		// Control these pointer again ... it can be, that another instance will be faster then these!
190*cdf0e10cSrcweir 		if ( pID == NULL )
191*cdf0e10cSrcweir 		{
192*cdf0e10cSrcweir 			// Create a new static ID ...
193*cdf0e10cSrcweir 			static ::cppu::OImplementationId aID( sal_False ) ;
194*cdf0e10cSrcweir 			// ... and set his address to static pointer!
195*cdf0e10cSrcweir 			pID = &aID ;
196*cdf0e10cSrcweir 		}
197*cdf0e10cSrcweir 	}
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 	return pID->getImplementationId() ;
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204