merge the formfield patch from ooo-build
[ooovba.git] / framework / source / classes / actiontriggercontainer.cxx
blob95649fabd406448883005addc2fc1c7fa93b2d84
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: actiontriggercontainer.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
33 #include <classes/actiontriggercontainer.hxx>
34 #include <cppuhelper/typeprovider.hxx>
36 #include <classes/actiontriggerpropertyset.hxx>
37 #include <classes/actiontriggerseparatorpropertyset.hxx>
39 using namespace cppu;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::lang;
42 using namespace com::sun::star::container;
44 namespace framework
47 ActionTriggerContainer::ActionTriggerContainer( const Reference< XMultiServiceFactory >& rServiceManager ) :
48 PropertySetContainer( rServiceManager )
53 ActionTriggerContainer::~ActionTriggerContainer()
57 // XInterface
58 Any SAL_CALL ActionTriggerContainer::queryInterface( const Type& aType )
59 throw ( RuntimeException )
61 Any a = ::cppu::queryInterface(
62 aType ,
63 SAL_STATIC_CAST( XMultiServiceFactory*, this ),
64 SAL_STATIC_CAST( XServiceInfo* , this ));
66 if( a.hasValue() )
68 return a;
71 return PropertySetContainer::queryInterface( aType );
74 void ActionTriggerContainer::acquire() throw()
76 PropertySetContainer::acquire();
79 void ActionTriggerContainer::release() throw()
81 PropertySetContainer::release();
85 // XMultiServiceFactory
86 Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstance( const ::rtl::OUString& aServiceSpecifier )
87 throw ( ::com::sun::star::uno::Exception, RuntimeException)
89 if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGER ))
90 return (OWeakObject *)( new ActionTriggerPropertySet( m_xServiceManager ));
91 else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
92 return (OWeakObject *)( new ActionTriggerContainer( m_xServiceManager ));
93 else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR ))
94 return (OWeakObject *)( new ActionTriggerSeparatorPropertySet( m_xServiceManager ));
95 else
96 throw com::sun::star::uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown service specifier!" )), (OWeakObject *)this );
100 Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/ )
101 throw ( Exception, RuntimeException)
103 return createInstance( ServiceSpecifier );
107 Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getAvailableServiceNames()
108 throw ( RuntimeException )
110 Sequence< ::rtl::OUString > aSeq( 3 );
112 aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGER ));
113 aSeq[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
114 aSeq[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR ));
116 return aSeq;
119 // XServiceInfo
120 ::rtl::OUString SAL_CALL ActionTriggerContainer::getImplementationName()
121 throw ( RuntimeException )
123 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERCONTAINER ));
126 sal_Bool SAL_CALL ActionTriggerContainer::supportsService( const ::rtl::OUString& ServiceName )
127 throw ( RuntimeException )
129 if ( ServiceName.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
130 return sal_True;
132 return sal_False;
135 Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getSupportedServiceNames()
136 throw ( RuntimeException )
138 Sequence< ::rtl::OUString > seqServiceNames( 1 );
140 seqServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
141 return seqServiceNames;
144 // XTypeProvider
145 Sequence< Type > SAL_CALL ActionTriggerContainer::getTypes() throw ( RuntimeException )
147 // Optimize this method !
148 // We initialize a static variable only one time. And we don't must use a mutex at every call!
149 // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
150 static ::cppu::OTypeCollection* pTypeCollection = NULL ;
152 if ( pTypeCollection == NULL )
154 // Ready for multithreading; get global mutex for first call of this method only! see before
155 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
157 // Control these pointer again ... it can be, that another instance will be faster then these!
158 if ( pTypeCollection == NULL )
160 // Create a static typecollection ...
161 static ::cppu::OTypeCollection aTypeCollection(
162 ::getCppuType(( const Reference< XMultiServiceFactory >*)NULL ) ,
163 ::getCppuType(( const Reference< XIndexContainer >*)NULL ) ,
164 ::getCppuType(( const Reference< XIndexAccess >*)NULL ) ,
165 ::getCppuType(( const Reference< XIndexReplace >*)NULL ) ,
166 ::getCppuType(( const Reference< XServiceInfo >*)NULL ) ,
167 ::getCppuType(( const Reference< XTypeProvider >*)NULL ) ) ;
169 // ... and set his address to static pointer!
170 pTypeCollection = &aTypeCollection ;
174 return pTypeCollection->getTypes() ;
177 Sequence< sal_Int8 > SAL_CALL ActionTriggerContainer::getImplementationId() throw ( RuntimeException )
179 // Create one Id for all instances of this class.
180 // Use ethernet address to do this! (sal_True)
182 // Optimize this method
183 // We initialize a static variable only one time. And we don't must use a mutex at every call!
184 // For the first call; pID is NULL - for the second call pID is different from NULL!
185 static ::cppu::OImplementationId* pID = NULL ;
187 if ( pID == NULL )
189 // Ready for multithreading; get global mutex for first call of this method only! see before
190 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
192 // Control these pointer again ... it can be, that another instance will be faster then these!
193 if ( pID == NULL )
195 // Create a new static ID ...
196 static ::cppu::OImplementationId aID( sal_False ) ;
197 // ... and set his address to static pointer!
198 pID = &aID ;
202 return pID->getImplementationId() ;