1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svl.hxx" 30 #include "sal/types.h" 31 #include "rtl/ustring.hxx" 32 #include <cppuhelper/factory.hxx> 33 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 34 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35 #include <com/sun/star/registry/XRegistryKey.hpp> 36 #include <svl/svldllapi.h> 37 38 namespace css = com::sun::star; 39 using css::uno::Reference; 40 using css::uno::Sequence; 41 using rtl::OUString; 42 43 // ------------------------------------------------------------------------------------- 44 45 #define DECLARE_CREATEINSTANCE( ImplName ) \ 46 Reference< css::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& ); 47 48 DECLARE_CREATEINSTANCE( SvNumberFormatterServiceObj ) 49 DECLARE_CREATEINSTANCE( SvNumberFormatsSupplierServiceObject ) 50 DECLARE_CREATEINSTANCE( PathService ) 51 52 // ------------------------------------------------------------------------------------- 53 54 extern "C" 55 { 56 57 SVL_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment ( 58 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */) 59 { 60 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 61 } 62 63 SVL_DLLPUBLIC void* SAL_CALL component_getFactory ( 64 const sal_Char * pImplementationName, void * _pServiceManager, void * /* _pRegistryKey*/) 65 { 66 void * pResult = 0; 67 if ( _pServiceManager ) 68 { 69 Reference< css::lang::XSingleServiceFactory > xFactory; 70 if (rtl_str_compare( 71 pImplementationName, 72 "com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject") == 0) 73 { 74 Sequence< OUString > aServiceNames(1); 75 aServiceNames.getArray()[0] = 76 OUString::createFromAscii( "com.sun.star.util.NumberFormatsSupplier" ); 77 78 xFactory = ::cppu::createSingleFactory( 79 reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager), 80 OUString::createFromAscii( pImplementationName ), 81 SvNumberFormatsSupplierServiceObject_CreateInstance, 82 aServiceNames); 83 } 84 else if (rtl_str_compare( 85 pImplementationName, 86 "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject") == 0) 87 { 88 Sequence< OUString > aServiceNames(1); 89 aServiceNames.getArray()[0] = 90 OUString::createFromAscii( "com.sun.star.util.NumberFormatter" ); 91 92 xFactory = ::cppu::createSingleFactory( 93 reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager), 94 OUString::createFromAscii( pImplementationName ), 95 SvNumberFormatterServiceObj_CreateInstance, 96 aServiceNames); 97 } 98 else if (rtl_str_compare ( 99 pImplementationName, "com.sun.star.comp.svl.PathService") == 0) 100 { 101 Sequence< OUString > aServiceNames(1); 102 aServiceNames.getArray()[0] = 103 OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ); 104 xFactory = ::cppu::createSingleFactory ( 105 reinterpret_cast< css::lang::XMultiServiceFactory* >( _pServiceManager ), 106 OUString::createFromAscii( pImplementationName ), 107 PathService_CreateInstance, 108 aServiceNames); 109 } 110 if ( xFactory.is() ) 111 { 112 xFactory->acquire(); 113 pResult = xFactory.get(); 114 } 115 } 116 return pResult; 117 } 118 119 } // "C" 120 121