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_starmath.hxx" 30 #include <com/sun/star/lang/XServiceInfo.hpp> 31 #include <com/sun/star/registry/XRegistryKey.hpp> 32 #include <com/sun/star/uno/Sequence.h> 33 #include <rtl/ustring.hxx> 34 35 #include <sfx2/sfxmodelfactory.hxx> 36 37 #include "smdll.hxx" 38 #include "document.hxx" 39 #include "unomodel.hxx" 40 41 using namespace ::rtl; 42 using namespace ::com::sun::star; 43 using namespace ::com::sun::star::uno; 44 using namespace ::com::sun::star::lang; 45 46 //Math document 47 extern Sequence< OUString > SAL_CALL 48 SmDocument_getSupportedServiceNames() throw(); 49 extern OUString SAL_CALL 50 SmDocument_getImplementationName() throw(); 51 extern Reference< XInterface >SAL_CALL 52 SmDocument_createInstance(const Reference< XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags) throw( Exception ); 53 54 //MathML import 55 extern Sequence< OUString > SAL_CALL 56 SmXMLImport_getSupportedServiceNames() throw(); 57 extern OUString SAL_CALL 58 SmXMLImport_getImplementationName() throw(); 59 extern Reference< XInterface > SAL_CALL 60 SmXMLImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 61 extern Sequence< OUString > SAL_CALL 62 SmXMLImportMeta_getSupportedServiceNames() throw(); 63 extern OUString SAL_CALL 64 SmXMLImportMeta_getImplementationName() throw(); 65 extern Reference< XInterface > SAL_CALL 66 SmXMLImportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 67 extern Sequence< OUString > SAL_CALL 68 SmXMLImportSettings_getSupportedServiceNames() throw(); 69 extern OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw(); 70 extern Reference< XInterface > SAL_CALL 71 SmXMLImportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 72 73 //MathML export 74 extern Sequence< OUString > SAL_CALL 75 SmXMLExport_getSupportedServiceNames() throw(); 76 extern OUString SAL_CALL 77 SmXMLExport_getImplementationName() throw(); 78 extern Reference< XInterface > SAL_CALL 79 SmXMLExport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 80 extern Sequence< OUString > SAL_CALL 81 SmXMLExportMetaOOO_getSupportedServiceNames() throw(); 82 extern OUString SAL_CALL 83 SmXMLExportMetaOOO_getImplementationName() throw(); 84 extern Reference< XInterface > SAL_CALL 85 SmXMLExportMetaOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 86 extern Sequence< OUString > SAL_CALL 87 SmXMLExportMeta_getSupportedServiceNames() throw(); 88 extern OUString SAL_CALL 89 SmXMLExportMeta_getImplementationName() throw(); 90 extern Reference< XInterface > SAL_CALL 91 SmXMLExportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 92 extern Sequence< OUString > SAL_CALL 93 SmXMLExportSettingsOOO_getSupportedServiceNames() throw(); 94 extern OUString SAL_CALL 95 SmXMLExportSettingsOOO_getImplementationName() throw(); 96 extern Reference< XInterface > SAL_CALL 97 SmXMLExportSettingsOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 98 extern Sequence< OUString > SAL_CALL 99 SmXMLExportSettings_getSupportedServiceNames() throw(); 100 extern OUString SAL_CALL 101 SmXMLExportSettings_getImplementationName() throw(); 102 extern Reference< XInterface > SAL_CALL 103 SmXMLExportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 104 extern Sequence< OUString > SAL_CALL 105 SmXMLExportContent_getSupportedServiceNames() throw(); 106 extern OUString SAL_CALL 107 SmXMLExportContent_getImplementationName() throw(); 108 extern Reference< XInterface > SAL_CALL 109 SmXMLExportContent_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ); 110 111 112 extern "C" { 113 114 void SAL_CALL component_getImplementationEnvironment( 115 const sal_Char** ppEnvironmentTypeName, 116 uno_Environment** /*ppEnvironment*/ ) 117 { 118 *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; 119 } 120 121 void* SAL_CALL component_getFactory( const sal_Char* pImplementationName, 122 void* pServiceManager, 123 void* /*pRegistryKey*/ ) 124 { 125 // Set default return value for this operation - if it failed. 126 void* pReturn = NULL ; 127 128 if ( 129 ( pImplementationName != NULL ) && 130 ( pServiceManager != NULL ) 131 ) 132 { 133 // Define variables which are used in following macros. 134 Reference< XSingleServiceFactory > xFactory ; 135 Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; 136 137 if( SmXMLImport_getImplementationName().equalsAsciiL( 138 pImplementationName, strlen(pImplementationName)) ) 139 { 140 xFactory = ::cppu::createSingleFactory( xServiceManager, 141 SmXMLImport_getImplementationName(), 142 SmXMLImport_createInstance, 143 SmXMLImport_getSupportedServiceNames() ); 144 } 145 else if( SmXMLExport_getImplementationName().equalsAsciiL( 146 pImplementationName, strlen(pImplementationName)) ) 147 { 148 xFactory = ::cppu::createSingleFactory( xServiceManager, 149 SmXMLExport_getImplementationName(), 150 SmXMLExport_createInstance, 151 SmXMLExport_getSupportedServiceNames() ); 152 } 153 else if( SmXMLImportMeta_getImplementationName().equalsAsciiL( 154 pImplementationName, strlen(pImplementationName)) ) 155 { 156 xFactory = ::cppu::createSingleFactory( xServiceManager, 157 SmXMLImportMeta_getImplementationName(), 158 SmXMLImportMeta_createInstance, 159 SmXMLImportMeta_getSupportedServiceNames() ); 160 } 161 else if( SmXMLExportMetaOOO_getImplementationName().equalsAsciiL( 162 pImplementationName, strlen(pImplementationName)) ) 163 { 164 xFactory = ::cppu::createSingleFactory( xServiceManager, 165 SmXMLExportMetaOOO_getImplementationName(), 166 SmXMLExportMetaOOO_createInstance, 167 SmXMLExportMetaOOO_getSupportedServiceNames() ); 168 } 169 else if( SmXMLExportMeta_getImplementationName().equalsAsciiL( 170 pImplementationName, strlen(pImplementationName)) ) 171 { 172 xFactory = ::cppu::createSingleFactory( xServiceManager, 173 SmXMLExportMeta_getImplementationName(), 174 SmXMLExportMeta_createInstance, 175 SmXMLExportMeta_getSupportedServiceNames() ); 176 } 177 else if( SmXMLImportSettings_getImplementationName().equalsAsciiL( 178 pImplementationName, strlen(pImplementationName)) ) 179 { 180 xFactory = ::cppu::createSingleFactory( xServiceManager, 181 SmXMLImportSettings_getImplementationName(), 182 SmXMLImportSettings_createInstance, 183 SmXMLImportSettings_getSupportedServiceNames() ); 184 } 185 else if( SmXMLExportSettingsOOO_getImplementationName().equalsAsciiL( 186 pImplementationName, strlen(pImplementationName)) ) 187 { 188 xFactory = ::cppu::createSingleFactory( xServiceManager, 189 SmXMLExportSettingsOOO_getImplementationName(), 190 SmXMLExportSettingsOOO_createInstance, 191 SmXMLExportSettingsOOO_getSupportedServiceNames() ); 192 } 193 else if( SmXMLExportSettings_getImplementationName().equalsAsciiL( 194 pImplementationName, strlen(pImplementationName)) ) 195 { 196 xFactory = ::cppu::createSingleFactory( xServiceManager, 197 SmXMLExportSettings_getImplementationName(), 198 SmXMLExportSettings_createInstance, 199 SmXMLExportSettings_getSupportedServiceNames() ); 200 } 201 else if( SmXMLExportContent_getImplementationName().equalsAsciiL( 202 pImplementationName, strlen(pImplementationName)) ) 203 { 204 xFactory = ::cppu::createSingleFactory( xServiceManager, 205 SmXMLExportContent_getImplementationName(), 206 SmXMLExportContent_createInstance, 207 SmXMLExportContent_getSupportedServiceNames() ); 208 } 209 else if( SmDocument_getImplementationName().equalsAsciiL( 210 pImplementationName, strlen(pImplementationName)) ) 211 { 212 xFactory = ::sfx2::createSfxModelFactory( xServiceManager, 213 SmDocument_getImplementationName(), 214 SmDocument_createInstance, 215 SmDocument_getSupportedServiceNames() ); 216 } 217 218 219 // Factory is valid - service was found. 220 if ( xFactory.is() ) 221 { 222 xFactory->acquire(); 223 pReturn = xFactory.get(); 224 } 225 } 226 227 // Return with result of this operation. 228 return pReturn ; 229 } 230 } // extern "C" 231 232 233 234