xref: /aoo4110/main/sc/source/ui/unoobj/detreg.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 #include "scdetect.hxx"
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/registry/XRegistryKey.hpp>
30 #include <com/sun/star/uno/Sequence.h>
31 #include <sal/types.h>
32 #include <rtl/ustring.hxx>
33 
34 using ::rtl::OUString;
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::lang;
38 
39 extern "C" {
40 
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment **)41 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
42         const  sal_Char**   ppEnvironmentTypeName,
43         uno_Environment**   /* ppEnvironment */           )
44 {
45 	*ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
46 }
47 
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)48 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
49                                      void* pServiceManager,
50                                      void* /* pRegistryKey */ )
51 {
52 	// Set default return value for this operation - if it failed.
53 	void* pReturn = NULL ;
54 
55 	if	(
56 			( pImplementationName	!=	NULL ) &&
57 			( pServiceManager		!=	NULL )
58 		)
59 	{
60 		// Define variables which are used in following macros.
61         Reference< XSingleServiceFactory >   xFactory                                                                                                ;
62         Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
63 
64 		if( ScFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) )
65 		{
66 			xFactory.set(::cppu::createSingleFactory( xServiceManager,
67 			ScFilterDetect::impl_getStaticImplementationName(),
68 			ScFilterDetect::impl_createInstance,
69 			ScFilterDetect::impl_getStaticSupportedServiceNames() ));
70 		}
71 
72 		// Factory is valid - service was found.
73 		if ( xFactory.is() )
74 		{
75 			xFactory->acquire();
76 			pReturn = xFactory.get();
77 		}
78 	}
79 
80 	// Return with result of this operation.
81 	return pReturn ;
82 }
83 } // extern "C"
84 
85 
86 
87