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_svtools.hxx" 30 #include "sal/types.h" 31 #include "rtl/ustring.hxx" 32 #include <cppuhelper/factory.hxx> 33 #include <cppuhelper/weak.hxx> 34 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 35 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 36 #include <com/sun/star/registry/XRegistryKey.hpp> 37 #include <osl/diagnose.h> 38 #include <uno/mapping.hxx> 39 #include "provider.hxx" 40 #include "renderer.hxx" 41 #include "unowizard.hxx" 42 43 #include <com/sun/star/registry/XRegistryKey.hpp> 44 #include "comphelper/servicedecl.hxx" 45 46 #include "cppuhelper/implementationentry.hxx" 47 48 using namespace ::com::sun::star::uno; 49 using namespace ::com::sun::star::registry; 50 using namespace ::com::sun::star::lang; 51 using namespace unographic; 52 53 using rtl::OUString; 54 55 namespace sdecl = comphelper::service_decl; 56 57 namespace unographic { 58 extern sdecl::ServiceDecl const serviceDecl; 59 } 60 61 // ------------------------------------------------------------------------------------- 62 63 // for CreateInstance functions implemented elsewhere 64 #define DECLARE_CREATEINSTANCE( ImplName ) \ 65 Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& ); 66 67 // for CreateInstance functions implemented elsewhere, while the function is within a namespace 68 #define DECLARE_CREATEINSTANCE_NAMESPACE( nmspe, ImplName ) \ 69 namespace nmspe { \ 70 Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& ); \ 71 } 72 73 namespace 74 { 75 static struct ::cppu::ImplementationEntry s_aServiceEntries[] = 76 { 77 { 78 ::svt::uno::Wizard::Create, 79 ::svt::uno::Wizard::getImplementationName_static, 80 ::svt::uno::Wizard::getSupportedServiceNames_static, 81 ::cppu::createSingleComponentFactory, NULL, 0 82 }, 83 { 0, 0, 0, 0, 0, 0 } 84 }; 85 } 86 87 // ------------------------------------------------------------------------------------- 88 89 DECLARE_CREATEINSTANCE_NAMESPACE( svt, OAddressBookSourceDialogUno ) 90 DECLARE_CREATEINSTANCE( SvFilterOptionsDialog ) 91 DECLARE_CREATEINSTANCE_NAMESPACE( unographic, GraphicProvider ) 92 DECLARE_CREATEINSTANCE_NAMESPACE( unographic, GraphicRendererVCL ) 93 94 // ------------------------------------------------------------------------------------- 95 extern "C" 96 { 97 98 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment ( 99 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */) 100 { 101 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 102 } 103 104 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory ( 105 const sal_Char * pImplementationName, void * _pServiceManager, void * pRegistryKey) 106 { 107 void * pResult = 0; 108 if ( _pServiceManager ) 109 { 110 Reference< XSingleServiceFactory > xFactory; 111 if (rtl_str_compare ( 112 pImplementationName, "com.sun.star.comp.svtools.OAddressBookSourceDialogUno") == 0) 113 { 114 Sequence< OUString > aServiceNames(1); 115 aServiceNames.getArray()[0] = 116 OUString::createFromAscii( "com.sun.star.ui.AddressBookSourceDialog" ); 117 118 xFactory = ::cppu::createSingleFactory ( 119 reinterpret_cast< XMultiServiceFactory* >( _pServiceManager ), 120 OUString::createFromAscii( pImplementationName ), 121 svt::OAddressBookSourceDialogUno_CreateInstance, 122 aServiceNames); 123 } 124 else if (rtl_str_compare ( 125 pImplementationName, "com.sun.star.svtools.SvFilterOptionsDialog") == 0) 126 { 127 Sequence< OUString > aServiceNames(1); 128 aServiceNames.getArray()[0] = 129 OUString::createFromAscii( "com.sun.star.ui.dialogs.FilterOptionsDialog" ); 130 131 xFactory = ::cppu::createSingleFactory ( 132 reinterpret_cast< XMultiServiceFactory* >( _pServiceManager ), 133 OUString::createFromAscii( pImplementationName ), 134 SvFilterOptionsDialog_CreateInstance, 135 aServiceNames); 136 } 137 else if( 0 == GraphicProvider::getImplementationName_Static().compareToAscii( pImplementationName ) ) 138 { 139 xFactory = ::cppu::createOneInstanceFactory( 140 reinterpret_cast< lang::XMultiServiceFactory * >( _pServiceManager ), 141 GraphicProvider::getImplementationName_Static(), 142 GraphicProvider_CreateInstance, 143 GraphicProvider::getSupportedServiceNames_Static() ); 144 } 145 else if( 0 == GraphicRendererVCL::getImplementationName_Static().compareToAscii( pImplementationName ) ) 146 { 147 xFactory = ::cppu::createOneInstanceFactory( 148 reinterpret_cast< lang::XMultiServiceFactory * >( _pServiceManager ), 149 GraphicRendererVCL::getImplementationName_Static(), 150 GraphicRendererVCL_CreateInstance, 151 GraphicRendererVCL::getSupportedServiceNames_Static() ); 152 } 153 else 154 { 155 pResult = component_getFactoryHelper( pImplementationName, reinterpret_cast< lang::XMultiServiceFactory * >( _pServiceManager ),reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ), serviceDecl ); 156 if ( !pResult ) 157 pResult = ::cppu::component_getFactoryHelper( pImplementationName, _pServiceManager, pRegistryKey, s_aServiceEntries ); 158 } 159 160 if ( xFactory.is() ) 161 { 162 xFactory->acquire(); 163 pResult = xFactory.get(); 164 } 165 } 166 return pResult; 167 } 168 169 } // "C" 170 171