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