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