xref: /aoo42x/main/sw/source/ui/uno/unofreg.cxx (revision cdf0e10c)
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_sw.hxx"
30 #include "SwXFilterOptions.hxx"
31 #include "sal/types.h"
32 #include <osl/diagnose.h>
33 #include <uno/lbnames.h>
34 #include <cppuhelper/factory.hxx>
35 #include <sfx2/sfxmodelfactory.hxx>
36 #ifndef INCLUDED_STRING_H
37 #include <string.h>
38 #define INCLUDED_STRING_H
39 #endif
40 
41 using namespace rtl;
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::lang;
44 
45 // module
46 extern uno::Sequence< OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw();
47 extern OUString SAL_CALL SwUnoModule_getImplementationName() throw();
48 extern uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
49 
50 // writer documents
51 extern uno::Sequence< OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw();
52 extern OUString SAL_CALL SwTextDocument_getImplementationName() throw();
53 extern uno::Reference< uno::XInterface > SAL_CALL SwTextDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr, const sal_uInt64 _nCreationFlags ) throw( uno::Exception );
54 extern uno::Sequence< OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw();
55 extern OUString SAL_CALL SwWebDocument_getImplementationName() throw();
56 extern uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
57 extern uno::Sequence< OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw();
58 extern OUString SAL_CALL SwGlobalDocument_getImplementationName() throw();
59 extern uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
60 
61 // xml import
62 extern uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames() throw();
63 extern OUString SAL_CALL SwXMLImport_getImplementationName() throw();
64 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
65 extern uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames() throw();
66 extern OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw();
67 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
68 extern uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames() throw();
69 extern OUString SAL_CALL SwXMLImportContent_getImplementationName() throw();
70 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
71 
72 extern uno::Sequence< OUString > SAL_CALL     SwXMLImportMeta_getSupportedServiceNames() throw();
73 extern OUString SAL_CALL     SwXMLImportMeta_getImplementationName() throw();
74 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
75 
76 extern uno::Sequence< OUString > SAL_CALL SwXMLImportSettings_getSupportedServiceNames() throw();
77 extern OUString SAL_CALL SwXMLImportSettings_getImplementationName() throw();
78 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportSettings_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
79 
80 // xml export (OOo)
81 extern uno::Sequence< OUString > SAL_CALL SwXMLExportOOO_getSupportedServiceNames() throw();
82 extern OUString SAL_CALL SwXMLExportOOO_getImplementationName() throw();
83 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
84 extern uno::Sequence< OUString > SAL_CALL SwXMLExportContentOOO_getSupportedServiceNames() throw();
85 extern OUString SAL_CALL SwXMLExportContentOOO_getImplementationName() throw();
86 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportContentOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
87 extern uno::Sequence< OUString > SAL_CALL SwXMLExportStylesOOO_getSupportedServiceNames() throw();
88 extern OUString SAL_CALL SwXMLExportStylesOOO_getImplementationName() throw();
89 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportStylesOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
90 extern uno::Sequence< OUString > SAL_CALL SwXMLExportMetaOOO_getSupportedServiceNames() throw();
91 extern OUString SAL_CALL SwXMLExportMetaOOO_getImplementationName() throw();
92 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportMetaOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
93 extern uno::Sequence< OUString > SAL_CALL SwXMLExportSettingsOOO_getSupportedServiceNames() throw();
94 extern OUString SAL_CALL SwXMLExportSettingsOOO_getImplementationName() throw();
95 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportSettingsOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
96 
97 // xml export (OASIS)
98 extern uno::Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames() throw();
99 extern OUString SAL_CALL SwXMLExport_getImplementationName() throw();
100 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExport_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
101 extern uno::Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames() throw();
102 extern OUString SAL_CALL SwXMLExportContent_getImplementationName() throw();
103 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportContent_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
104 extern uno::Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames() throw();
105 extern OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw();
106 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportStyles_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
107 extern uno::Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames() throw();
108 extern OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw();
109 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportMeta_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
110 extern uno::Sequence< OUString > SAL_CALL SwXMLExportSettings_getSupportedServiceNames() throw();
111 extern OUString SAL_CALL SwXMLExportSettings_getImplementationName() throw();
112 extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportSettings_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr)	throw( uno::Exception );
113 
114 //API objects
115 extern uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw();
116 extern OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw();
117 extern uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
118 
119 extern uno::Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw();
120 extern OUString SAL_CALL SwXModule_getImplementationName() throw();
121 extern uno::Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
122 
123 extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
124 extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
125 extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
126 
127 extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
128 extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
129 extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
130 
131 // --> OD 2007-05-24 #i73788#
132 #include "cppuhelper/implementationentry.hxx"
133 namespace comp_FinalThreadManager {
134 
135 // component and service helper functions:
136 ::rtl::OUString SAL_CALL _getImplementationName();
137 com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames();
138 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL _create(
139     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context );
140 
141 }
142 // <--
143 
144 //
145 #ifdef __cplusplus
146 extern "C"
147 {
148 #endif
149 
150 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
151 		const sal_Char ** ppEnvTypeName,
152         uno_Environment ** /*ppEnv*/ )
153 {
154 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
155 }
156 
157 static ::cppu::ImplementationEntry const entries[] = {
158     { &comp_FinalThreadManager::_create,
159       &comp_FinalThreadManager::_getImplementationName,
160       &comp_FinalThreadManager::_getSupportedServiceNames,
161       &::cppu::createSingleComponentFactory, 0, 0 },
162     { 0, 0, 0, 0, 0, 0 }
163 };
164 
165 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
166 	const sal_Char * pImplName,
167 	void * pServiceManager,
168     void * pRegistryKey )
169 {
170 	void * pRet = 0;
171 	if( pServiceManager )
172 	{
173 		uno::Reference< XMultiServiceFactory > xMSF(
174 			reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
175 
176 		uno::Reference< XSingleServiceFactory > xFactory;
177 
178 		const sal_Int32 nImplNameLen = strlen( pImplName );
179 		if( SwXMLImport_getImplementationName().equalsAsciiL( pImplName,
180 															  nImplNameLen ) )
181 		{
182 			xFactory = ::cppu::createSingleFactory( xMSF,
183 				SwXMLImport_getImplementationName(),
184 				SwXMLImport_createInstance,
185 				SwXMLImport_getSupportedServiceNames() );
186 		}
187 		else if( SwXMLImportStyles_getImplementationName().equalsAsciiL(
188 													pImplName, nImplNameLen ) )
189 		{
190 			xFactory = ::cppu::createSingleFactory( xMSF,
191 				SwXMLImportStyles_getImplementationName(),
192 				SwXMLImportStyles_createInstance,
193 				SwXMLImportStyles_getSupportedServiceNames() );
194 		}
195 		else if( SwXMLImportContent_getImplementationName().equalsAsciiL(
196 													pImplName, nImplNameLen ) )
197 		{
198 			xFactory = ::cppu::createSingleFactory( xMSF,
199 				SwXMLImportContent_getImplementationName(),
200 				SwXMLImportContent_createInstance,
201 				SwXMLImportContent_getSupportedServiceNames() );
202 		}
203 		else if( SwXMLImportMeta_getImplementationName().equalsAsciiL(
204 													pImplName, nImplNameLen ) )
205 		{
206 			xFactory = ::cppu::createSingleFactory( xMSF,
207 				SwXMLImportMeta_getImplementationName(),
208 				SwXMLImportMeta_createInstance,
209 				SwXMLImportMeta_getSupportedServiceNames() );
210 		}
211 		else if( SwXMLImportSettings_getImplementationName().equalsAsciiL(
212 													pImplName, nImplNameLen ) )
213 		{
214 			xFactory = ::cppu::createSingleFactory( xMSF,
215 				SwXMLImportSettings_getImplementationName(),
216 				SwXMLImportSettings_createInstance,
217 				SwXMLImportSettings_getSupportedServiceNames() );
218 		}
219 		else if( SwXMLExportOOO_getImplementationName().equalsAsciiL( pImplName,
220 															nImplNameLen ) )
221 		{
222 			xFactory = ::cppu::createSingleFactory( xMSF,
223 				SwXMLExportOOO_getImplementationName(),
224 				SwXMLExportOOO_createInstance,
225 				SwXMLExportOOO_getSupportedServiceNames() );
226 		}
227 		else if( SwXMLExportStylesOOO_getImplementationName().equalsAsciiL(
228 													pImplName, nImplNameLen ) )
229 		{
230 			xFactory = ::cppu::createSingleFactory( xMSF,
231 				SwXMLExportStylesOOO_getImplementationName(),
232 				SwXMLExportStylesOOO_createInstance,
233 				SwXMLExportStylesOOO_getSupportedServiceNames() );
234 		}
235 		else if( SwXMLExportContentOOO_getImplementationName().equalsAsciiL(
236 													pImplName, nImplNameLen ) )
237 		{
238 			xFactory = ::cppu::createSingleFactory( xMSF,
239 				SwXMLExportContentOOO_getImplementationName(),
240 				SwXMLExportContentOOO_createInstance,
241 				SwXMLExportContentOOO_getSupportedServiceNames() );
242 		}
243 		else if( SwXMLExportMetaOOO_getImplementationName().equalsAsciiL(
244 													pImplName, nImplNameLen ) )
245 		{
246 			xFactory = ::cppu::createSingleFactory( xMSF,
247 				SwXMLExportMetaOOO_getImplementationName(),
248 				SwXMLExportMetaOOO_createInstance,
249 				SwXMLExportMetaOOO_getSupportedServiceNames() );
250 		}
251 		else if( SwXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
252 													pImplName, nImplNameLen ) )
253 		{
254 			xFactory = ::cppu::createSingleFactory( xMSF,
255 				SwXMLExportSettingsOOO_getImplementationName(),
256 				SwXMLExportSettingsOOO_createInstance,
257 				SwXMLExportSettingsOOO_getSupportedServiceNames() );
258 		}
259 		else if( SwXMLExport_getImplementationName().equalsAsciiL( pImplName,
260 															nImplNameLen ) )
261 		{
262 			xFactory = ::cppu::createSingleFactory( xMSF,
263 				SwXMLExport_getImplementationName(),
264 				SwXMLExport_createInstance,
265 				SwXMLExport_getSupportedServiceNames() );
266 		}
267 		else if( SwXMLExportStyles_getImplementationName().equalsAsciiL(
268 													pImplName, nImplNameLen ) )
269 		{
270 			xFactory = ::cppu::createSingleFactory( xMSF,
271 				SwXMLExportStyles_getImplementationName(),
272 				SwXMLExportStyles_createInstance,
273 				SwXMLExportStyles_getSupportedServiceNames() );
274 		}
275 		else if( SwXMLExportContent_getImplementationName().equalsAsciiL(
276 													pImplName, nImplNameLen ) )
277 		{
278 			xFactory = ::cppu::createSingleFactory( xMSF,
279 				SwXMLExportContent_getImplementationName(),
280 				SwXMLExportContent_createInstance,
281 				SwXMLExportContent_getSupportedServiceNames() );
282 		}
283 		else if( SwXMLExportMeta_getImplementationName().equalsAsciiL(
284 													pImplName, nImplNameLen ) )
285 		{
286 			xFactory = ::cppu::createSingleFactory( xMSF,
287 				SwXMLExportMeta_getImplementationName(),
288 				SwXMLExportMeta_createInstance,
289 				SwXMLExportMeta_getSupportedServiceNames() );
290 		}
291 		else if( SwXMLExportSettings_getImplementationName().equalsAsciiL(
292 													pImplName, nImplNameLen ) )
293 		{
294 			xFactory = ::cppu::createSingleFactory( xMSF,
295 				SwXMLExportSettings_getImplementationName(),
296 				SwXMLExportSettings_createInstance,
297 				SwXMLExportSettings_getSupportedServiceNames() );
298 		}
299         else if( SwXAutoTextContainer_getImplementationName().equalsAsciiL(
300 													pImplName, nImplNameLen ) )
301 		{
302 			xFactory = ::cppu::createSingleFactory( xMSF,
303                 SwXAutoTextContainer_getImplementationName(),
304                 SwXAutoTextContainer_createInstance,
305                 SwXAutoTextContainer_getSupportedServiceNames() );
306 		}
307         else if( SwXModule_getImplementationName().equalsAsciiL(
308 													pImplName, nImplNameLen ) )
309 		{
310 			xFactory = ::cppu::createSingleFactory( xMSF,
311                 SwXModule_getImplementationName(),
312                 SwXModule_createInstance,
313                 SwXModule_getSupportedServiceNames() );
314 		}
315         else if( SwXMailMerge_getImplementationName().equalsAsciiL(
316                                                     pImplName, nImplNameLen ) )
317         {
318             xFactory = ::cppu::createSingleFactory( xMSF,
319                 SwXMailMerge_getImplementationName(),
320                 SwXMailMerge_createInstance,
321                 SwXMailMerge_getSupportedServiceNames() );
322         }
323         else if( SwXFilterOptions::getImplementationName_Static().equalsAsciiL(
324 													pImplName, nImplNameLen ) )
325 		{
326 			xFactory = ::cppu::createSingleFactory( xMSF,
327                 SwXFilterOptions::getImplementationName_Static(),
328                 SwXFilterOptions_createInstance,
329                 SwXFilterOptions::getSupportedServiceNames_Static() );
330 		}
331         else if( SwTextDocument_getImplementationName().equalsAsciiL(
332 													pImplName, nImplNameLen ) )
333 		{
334 			xFactory = ::sfx2::createSfxModelFactory( xMSF,
335                 SwTextDocument_getImplementationName(),
336                 SwTextDocument_createInstance,
337                 SwTextDocument_getSupportedServiceNames() );
338 		}
339         else if( SwWebDocument_getImplementationName().equalsAsciiL(
340 													pImplName, nImplNameLen ) )
341 		{
342 			xFactory = ::cppu::createSingleFactory( xMSF,
343                 SwWebDocument_getImplementationName(),
344                 SwWebDocument_createInstance,
345                 SwWebDocument_getSupportedServiceNames() );
346 		}
347         else if( SwGlobalDocument_getImplementationName().equalsAsciiL(
348 													pImplName, nImplNameLen ) )
349 		{
350 			xFactory = ::cppu::createSingleFactory( xMSF,
351                 SwGlobalDocument_getImplementationName(),
352                 SwGlobalDocument_createInstance,
353                 SwGlobalDocument_getSupportedServiceNames() );
354 		}
355         else if( SwUnoModule_getImplementationName().equalsAsciiL(
356 													pImplName, nImplNameLen ) )
357 		{
358 			xFactory = ::cppu::createSingleFactory( xMSF,
359                 SwUnoModule_getImplementationName(),
360                 SwUnoModule_createInstance,
361                 SwUnoModule_getSupportedServiceNames() );
362 		}
363         // --> OD 2007-05-24 #i73788#
364         else if( comp_FinalThreadManager::_getImplementationName().equalsAsciiL(
365                                                     pImplName, nImplNameLen ) )
366         {
367             pRet = ::cppu::component_getFactoryHelper(
368                         pImplName, pServiceManager, pRegistryKey, entries);
369         }
370         // <--
371 
372         if( xFactory.is())
373 		{
374 			xFactory->acquire();
375 			pRet = xFactory.get();
376 		}
377 	}
378 	return pRet;
379 }
380 
381 #ifdef __cplusplus
382 }
383 #endif
384