Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/lang/XServiceInfo.hpp>
21 : #include <com/sun/star/registry/XRegistryKey.hpp>
22 : #include <com/sun/star/uno/Sequence.h>
23 : #include <rtl/ustring.hxx>
24 :
25 : #include <sfx2/sfxmodelfactory.hxx>
26 :
27 : #include "smdll.hxx"
28 : #include "document.hxx"
29 : #include "unomodel.hxx"
30 :
31 : using namespace ::rtl;
32 : using namespace ::com::sun::star;
33 : using namespace ::com::sun::star::uno;
34 : using namespace ::com::sun::star::lang;
35 :
36 : //Math document
37 : extern Sequence< OUString > SAL_CALL
38 : SmDocument_getSupportedServiceNames() throw();
39 : extern OUString SAL_CALL
40 : SmDocument_getImplementationName() throw();
41 : extern Reference< XInterface >SAL_CALL
42 : SmDocument_createInstance(const Reference< XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags) throw( Exception );
43 :
44 : //MathML import
45 : extern Sequence< OUString > SAL_CALL
46 : SmXMLImport_getSupportedServiceNames() throw();
47 : extern OUString SAL_CALL
48 : SmXMLImport_getImplementationName() throw();
49 : extern Reference< XInterface > SAL_CALL
50 : SmXMLImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
51 : extern Sequence< OUString > SAL_CALL
52 : SmXMLImportMeta_getSupportedServiceNames() throw();
53 : extern OUString SAL_CALL
54 : SmXMLImportMeta_getImplementationName() throw();
55 : extern Reference< XInterface > SAL_CALL
56 : SmXMLImportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
57 : extern Sequence< OUString > SAL_CALL
58 : SmXMLImportSettings_getSupportedServiceNames() throw();
59 : extern OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw();
60 : extern Reference< XInterface > SAL_CALL
61 : SmXMLImportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
62 :
63 : //MathML export
64 : extern Sequence< OUString > SAL_CALL
65 : SmXMLExport_getSupportedServiceNames() throw();
66 : extern OUString SAL_CALL
67 : SmXMLExport_getImplementationName() throw();
68 : extern Reference< XInterface > SAL_CALL
69 : SmXMLExport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
70 : extern Sequence< OUString > SAL_CALL
71 : SmXMLExportMetaOOO_getSupportedServiceNames() throw();
72 : extern OUString SAL_CALL
73 : SmXMLExportMetaOOO_getImplementationName() throw();
74 : extern Reference< XInterface > SAL_CALL
75 : SmXMLExportMetaOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
76 : extern Sequence< OUString > SAL_CALL
77 : SmXMLExportMeta_getSupportedServiceNames() throw();
78 : extern OUString SAL_CALL
79 : SmXMLExportMeta_getImplementationName() throw();
80 : extern Reference< XInterface > SAL_CALL
81 : SmXMLExportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
82 : extern Sequence< OUString > SAL_CALL
83 : SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
84 : extern OUString SAL_CALL
85 : SmXMLExportSettingsOOO_getImplementationName() throw();
86 : extern Reference< XInterface > SAL_CALL
87 : SmXMLExportSettingsOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
88 : extern Sequence< OUString > SAL_CALL
89 : SmXMLExportSettings_getSupportedServiceNames() throw();
90 : extern OUString SAL_CALL
91 : SmXMLExportSettings_getImplementationName() throw();
92 : extern Reference< XInterface > SAL_CALL
93 : SmXMLExportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
94 : extern Sequence< OUString > SAL_CALL
95 : SmXMLExportContent_getSupportedServiceNames() throw();
96 : extern OUString SAL_CALL
97 : SmXMLExportContent_getImplementationName() throw();
98 : extern Reference< XInterface > SAL_CALL
99 : SmXMLExportContent_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
100 :
101 :
102 : extern "C" {
103 :
104 9 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL sm_component_getFactory( const sal_Char* pImplementationName,
105 : void* pServiceManager,
106 : void* /*pRegistryKey*/ )
107 : {
108 : // Set default return value for this operation - if it failed.
109 9 : void* pReturn = NULL ;
110 :
111 9 : if (
112 : ( pImplementationName != NULL ) &&
113 : ( pServiceManager != NULL )
114 : )
115 : {
116 : // Define variables which are used in following macros.
117 9 : Reference< XSingleServiceFactory > xFactory ;
118 9 : Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
119 :
120 9 : if( SmXMLImport_getImplementationName().equalsAscii( pImplementationName ))
121 : {
122 : xFactory = ::cppu::createSingleFactory( xServiceManager,
123 : SmXMLImport_getImplementationName(),
124 : SmXMLImport_createInstance,
125 0 : SmXMLImport_getSupportedServiceNames() );
126 : }
127 9 : else if( SmXMLExport_getImplementationName().equalsAscii( pImplementationName ))
128 : {
129 : xFactory = ::cppu::createSingleFactory( xServiceManager,
130 : SmXMLExport_getImplementationName(),
131 : SmXMLExport_createInstance,
132 0 : SmXMLExport_getSupportedServiceNames() );
133 : }
134 9 : else if( SmXMLImportMeta_getImplementationName().equalsAscii( pImplementationName ))
135 : {
136 : xFactory = ::cppu::createSingleFactory( xServiceManager,
137 : SmXMLImportMeta_getImplementationName(),
138 : SmXMLImportMeta_createInstance,
139 0 : SmXMLImportMeta_getSupportedServiceNames() );
140 : }
141 9 : else if( SmXMLExportMetaOOO_getImplementationName().equalsAscii( pImplementationName ))
142 : {
143 : xFactory = ::cppu::createSingleFactory( xServiceManager,
144 : SmXMLExportMetaOOO_getImplementationName(),
145 : SmXMLExportMetaOOO_createInstance,
146 0 : SmXMLExportMetaOOO_getSupportedServiceNames() );
147 : }
148 9 : else if( SmXMLExportMeta_getImplementationName().equalsAscii( pImplementationName ))
149 : {
150 : xFactory = ::cppu::createSingleFactory( xServiceManager,
151 : SmXMLExportMeta_getImplementationName(),
152 : SmXMLExportMeta_createInstance,
153 0 : SmXMLExportMeta_getSupportedServiceNames() );
154 : }
155 9 : else if( SmXMLImportSettings_getImplementationName().equalsAscii( pImplementationName ))
156 : {
157 : xFactory = ::cppu::createSingleFactory( xServiceManager,
158 : SmXMLImportSettings_getImplementationName(),
159 : SmXMLImportSettings_createInstance,
160 0 : SmXMLImportSettings_getSupportedServiceNames() );
161 : }
162 9 : else if( SmXMLExportSettingsOOO_getImplementationName().equalsAscii( pImplementationName ))
163 : {
164 : xFactory = ::cppu::createSingleFactory( xServiceManager,
165 : SmXMLExportSettingsOOO_getImplementationName(),
166 : SmXMLExportSettingsOOO_createInstance,
167 0 : SmXMLExportSettingsOOO_getSupportedServiceNames() );
168 : }
169 9 : else if( SmXMLExportSettings_getImplementationName().equalsAscii( pImplementationName ))
170 : {
171 : xFactory = ::cppu::createSingleFactory( xServiceManager,
172 : SmXMLExportSettings_getImplementationName(),
173 : SmXMLExportSettings_createInstance,
174 3 : SmXMLExportSettings_getSupportedServiceNames() );
175 : }
176 6 : else if( SmXMLExportContent_getImplementationName().equalsAscii( pImplementationName ))
177 : {
178 : xFactory = ::cppu::createSingleFactory( xServiceManager,
179 : SmXMLExportContent_getImplementationName(),
180 : SmXMLExportContent_createInstance,
181 3 : SmXMLExportContent_getSupportedServiceNames() );
182 : }
183 3 : else if( SmDocument_getImplementationName().equalsAscii( pImplementationName ))
184 : {
185 : xFactory = ::sfx2::createSfxModelFactory( xServiceManager,
186 : SmDocument_getImplementationName(),
187 : SmDocument_createInstance,
188 3 : SmDocument_getSupportedServiceNames() );
189 : }
190 :
191 :
192 : // Factory is valid - service was found.
193 9 : if ( xFactory.is() )
194 : {
195 9 : xFactory->acquire();
196 9 : pReturn = xFactory.get();
197 9 : }
198 : }
199 :
200 : // Return with result of this operation.
201 9 : return pReturn ;
202 : }
203 12 : } // extern "C"
204 :
205 :
206 :
207 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|