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_svl.hxx"
26 #include "sal/types.h"
27 #include "rtl/ustring.hxx"
28 #include <cppuhelper/factory.hxx>
29 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/registry/XRegistryKey.hpp>
32 #include <svl/svldllapi.h>
33 
34 namespace css = com::sun::star;
35 using css::uno::Reference;
36 using css::uno::Sequence;
37 using rtl::OUString;
38 
39 // -------------------------------------------------------------------------------------
40 
41 #define DECLARE_CREATEINSTANCE( ImplName ) \
42 	Reference< css::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& );
43 
44 DECLARE_CREATEINSTANCE( SvNumberFormatterServiceObj )
DECLARE_CREATEINSTANCE(SvNumberFormatsSupplierServiceObject)45 DECLARE_CREATEINSTANCE( SvNumberFormatsSupplierServiceObject )
46 DECLARE_CREATEINSTANCE( PathService )
47 
48 // -------------------------------------------------------------------------------------
49 
50 extern "C"
51 {
52 
53 SVL_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment (
54 	const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */)
55 {
56 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
57 }
58 
59 SVL_DLLPUBLIC void* SAL_CALL component_getFactory (
60 	const sal_Char * pImplementationName, void * _pServiceManager, void * /* _pRegistryKey*/)
61 {
62 	void * pResult = 0;
63 	if ( _pServiceManager )
64 	{
65 		Reference< css::lang::XSingleServiceFactory > xFactory;
66 		if (rtl_str_compare(
67 				pImplementationName,
68 				"com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject") == 0)
69 		{
70 			Sequence< OUString > aServiceNames(1);
71 			aServiceNames.getArray()[0] =
72 				OUString::createFromAscii( "com.sun.star.util.NumberFormatsSupplier" );
73 
74             xFactory = ::cppu::createSingleFactory(
75 				reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
76 				OUString::createFromAscii( pImplementationName ),
77 				SvNumberFormatsSupplierServiceObject_CreateInstance,
78 				aServiceNames);
79 		}
80 		else if (rtl_str_compare(
81 					 pImplementationName,
82 					 "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject") == 0)
83 		{
84 			Sequence< OUString > aServiceNames(1);
85 			aServiceNames.getArray()[0] =
86 				OUString::createFromAscii( "com.sun.star.util.NumberFormatter" );
87 
88             xFactory = ::cppu::createSingleFactory(
89 				reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
90 				OUString::createFromAscii( pImplementationName ),
91 				SvNumberFormatterServiceObj_CreateInstance,
92 				aServiceNames);
93 		}
94 		else if (rtl_str_compare (
95 					 pImplementationName, "com.sun.star.comp.svl.PathService") == 0)
96 		{
97 			Sequence< OUString > aServiceNames(1);
98             aServiceNames.getArray()[0] =
99 				OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" );
100             xFactory = ::cppu::createSingleFactory (
101 				reinterpret_cast< css::lang::XMultiServiceFactory* >( _pServiceManager ),
102 				OUString::createFromAscii( pImplementationName ),
103 				PathService_CreateInstance,
104 				aServiceNames);
105 		}
106 		if ( xFactory.is() )
107 		{
108 			xFactory->acquire();
109 			pResult = xFactory.get();
110 		}
111 	}
112 	return pResult;
113 }
114 
115 }	// "C"
116 
117