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_basctl.hxx"
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/registry/XRegistryKey.hpp>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <rtl/ustring.hxx>
30 
31 #include <cppuhelper/factory.hxx>
32 
33 #include "unomodel.hxx"
34 
35 using ::rtl::OUString;
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 
40 
41 extern "C" {
42 
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment ** ppEnvironment)43 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
44         const  sal_Char**   ppEnvironmentTypeName,
45         uno_Environment**   ppEnvironment           )
46 {
47 	(void)ppEnvironment;
48 	*ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
49 }
50 
51 SAL_DLLPUBLIC_EXPORT
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void * pRegistryKey)52 void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
53                                      void* pServiceManager,
54                                      void* pRegistryKey )
55 {
56 	(void)pRegistryKey;
57 
58 	// Set default return value for this operation - if it failed.
59 	void* pReturn = NULL ;
60 
61 	if	(
62 			( pImplementationName	!=	NULL ) &&
63 			( pServiceManager		!=	NULL )
64 		)
65 	{
66 		// Define variables which are used in following macros.
67         Reference< XSingleServiceFactory >   xFactory                                                                                                ;
68         Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
69 
70 		if( SIDEModel::getImplementationName_Static().equalsAscii( pImplementationName ) )
71 		{
72 			xFactory = ::cppu::createSingleFactory( xServiceManager,
73 			SIDEModel::getImplementationName_Static(),
74 			SIDEModel_createInstance,
75 			SIDEModel::getSupportedServiceNames_Static() );
76 		}
77 
78 		// Factory is valid - service was found.
79 		if ( xFactory.is() )
80 		{
81 			xFactory->acquire();
82 			pReturn = xFactory.get();
83 		}
84 	}
85 
86 	// Return with result of this operation.
87 	return pReturn ;
88 }
89 } // extern "C"
90 
91 
92 
93