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