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_sd.hxx"
26 #include <com/sun/star/registry/XRegistryKey.hpp>
27
28 #include "sddll.hxx"
29
30 #include <cppuhelper/factory.hxx>
31 #include <uno/lbnames.h>
32 #include <sfx2/sfxmodelfactory.hxx>
33 #include "osl/diagnose.h"
34 #include "sal/types.h"
35
36 #ifndef INCLUDED_STRING_H
37 #include <string.h>
38 #define INCLUDED_STRING_H
39 #endif
40 #include <comphelper/stl_types.hxx>
41 #include <hash_map>
42 #include <boost/shared_ptr.hpp>
43
44 using namespace rtl;
45 using namespace com::sun::star;
46
47
48 // Forward declarations of the factories.
49
50 extern uno::Reference< uno::XInterface > SAL_CALL SdDrawingDocument_createInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory, const sal_uInt64 _nCreationFlags );
51 extern OUString SdDrawingDocument_getImplementationName() throw( uno::RuntimeException );
52 extern uno::Sequence< OUString > SAL_CALL SdDrawingDocument_getSupportedServiceNames() throw( uno::RuntimeException );
53
54 extern uno::Reference< uno::XInterface > SAL_CALL SdPresentationDocument_createInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory, const sal_uInt64 _nCreationFlags );
55 extern OUString SdPresentationDocument_getImplementationName() throw( uno::RuntimeException );
56 extern uno::Sequence< OUString > SAL_CALL SdPresentationDocument_getSupportedServiceNames() throw( uno::RuntimeException );
57
58 extern uno::Reference< uno::XInterface > SAL_CALL SdHtmlOptionsDialog_CreateInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory );
59 extern OUString SdHtmlOptionsDialog_getImplementationName() throw( uno::RuntimeException );
60 extern uno::Sequence< OUString > SAL_CALL SdHtmlOptionsDialog_getSupportedServiceNames() throw( uno::RuntimeException );
61
62 extern uno::Reference< uno::XInterface > SAL_CALL SdUnoModule_createInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory );
63 extern OUString SdUnoModule_getImplementationName() throw( uno::RuntimeException );
64 extern uno::Sequence< OUString > SAL_CALL SdUnoModule_getSupportedServiceNames() throw( uno::RuntimeException );
65
66 namespace sd
67 {
68 extern uno::Reference< uno::XInterface > SAL_CALL RandomNode_createInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory );
69 extern OUString RandomNode__getImplementationName() throw( uno::RuntimeException );
70 extern uno::Sequence< OUString > SAL_CALL RandomNode_getSupportedServiceNames() throw( uno::RuntimeException );
71
72 extern uno::Reference< uno::XInterface > SAL_CALL SlideLayoutController_createInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory );
73 extern OUString SlideLayoutController_getImplementationName() throw( uno::RuntimeException );
74 extern uno::Sequence< OUString > SlideLayoutController_getSupportedServiceNames() throw( uno::RuntimeException );
75
76 extern uno::Reference< uno::XInterface > SAL_CALL InsertSlideController_createInstance( const uno::Reference< lang::XMultiServiceFactory > & _rxFactory );
77 extern OUString InsertSlideController_getImplementationName() throw( uno::RuntimeException );
78 extern uno::Sequence< OUString > InsertSlideController_getSupportedServiceNames() throw( uno::RuntimeException );
79 }
80
81 namespace sd { namespace framework {
82
83 extern uno::Reference<uno::XInterface> SAL_CALL Configuration_createInstance(
84 const uno::Reference<uno::XComponentContext>& rxContext)
85 throw(uno::Exception);
86 extern OUString Configuration_getImplementationName(void) throw (uno::RuntimeException);
87 extern uno::Sequence<OUString> SAL_CALL Configuration_getSupportedServiceNames (void)
88 throw (uno::RuntimeException);
89
90 extern uno::Reference<uno::XInterface> SAL_CALL ConfigurationController_createInstance(
91 const uno::Reference<uno::XComponentContext>& rxContext)
92 throw(uno::Exception);
93 extern OUString ConfigurationController_getImplementationName(void) throw (uno::RuntimeException);
94 extern uno::Sequence<OUString> SAL_CALL ConfigurationController_getSupportedServiceNames (void)
95 throw (uno::RuntimeException);
96
97 extern uno::Reference<uno::XInterface> SAL_CALL ModuleController_createInstance(
98 const uno::Reference<uno::XComponentContext>& rxContext)
99 throw(uno::Exception);
100 extern OUString ModuleController_getImplementationName(void) throw (uno::RuntimeException);
101 extern uno::Sequence<OUString> SAL_CALL ModuleController_getSupportedServiceNames (void)
102 throw (uno::RuntimeException);
103
104 extern uno::Reference<uno::XInterface> SAL_CALL BasicPaneFactory_createInstance(
105 const uno::Reference<uno::XComponentContext>& rxContext)
106 throw(uno::Exception);
107 extern OUString BasicPaneFactory_getImplementationName(void) throw (uno::RuntimeException);
108 extern uno::Sequence<OUString> SAL_CALL BasicPaneFactory_getSupportedServiceNames (void)
109 throw (uno::RuntimeException);
110
111 extern uno::Reference<uno::XInterface> SAL_CALL BasicToolBarFactory_createInstance(
112 const uno::Reference<uno::XComponentContext>& rxContext)
113 throw(uno::Exception);
114 extern OUString BasicToolBarFactory_getImplementationName(void) throw (uno::RuntimeException);
115 extern uno::Sequence<OUString> SAL_CALL BasicToolBarFactory_getSupportedServiceNames (void)
116 throw (uno::RuntimeException);
117
118 extern uno::Reference<uno::XInterface> SAL_CALL BasicViewFactory_createInstance(
119 const uno::Reference<uno::XComponentContext>& rxContext)
120 throw(uno::Exception);
121 extern OUString BasicViewFactory_getImplementationName(void) throw (uno::RuntimeException);
122 extern uno::Sequence<OUString> SAL_CALL BasicViewFactory_getSupportedServiceNames (void)
123 throw (uno::RuntimeException);
124
125 extern uno::Reference<uno::XInterface> SAL_CALL ResourceId_createInstance(
126 const uno::Reference<uno::XComponentContext>& rxContext)
127 throw(uno::Exception);
128 extern OUString ResourceId_getImplementationName(void) throw (uno::RuntimeException);
129 extern uno::Sequence<OUString> SAL_CALL ResourceId_getSupportedServiceNames (void)
130 throw (uno::RuntimeException);
131
132 extern uno::Reference<uno::XInterface> SAL_CALL PresentationFactoryProvider_createInstance(
133 const uno::Reference<uno::XComponentContext>& rxContext)
134 throw(uno::Exception);
135 extern OUString PresentationFactoryProvider_getImplementationName(void)
136 throw (uno::RuntimeException);
137 extern uno::Sequence<OUString> SAL_CALL PresentationFactoryProvider_getSupportedServiceNames (void)
138 throw (uno::RuntimeException);
139 } }
140
141 namespace sd { namespace sidebar {
142
143 extern uno::Reference<uno::XInterface> SAL_CALL PanelFactory_createInstance(
144 const uno::Reference<uno::XComponentContext>& rxContext)
145 throw(uno::Exception);
146 extern OUString PanelFactory_getImplementationName(void) throw (uno::RuntimeException);
147 extern uno::Sequence<OUString> SAL_CALL PanelFactory_getSupportedServiceNames (void)
148 throw (uno::RuntimeException);
149
150 } }
151
152 namespace sd { namespace presenter {
153 extern uno::Reference<uno::XInterface> SAL_CALL SlideRenderer_createInstance(
154 const uno::Reference<uno::XComponentContext>& rxContext)
155 throw(uno::Exception);
156 extern OUString SlideRenderer_getImplementationName(void)
157 throw (uno::RuntimeException);
158 extern uno::Sequence<OUString> SAL_CALL SlideRenderer_getSupportedServiceNames (void)
159 throw (uno::RuntimeException);
160
161 extern uno::Reference<uno::XInterface> SAL_CALL PresenterCanvas_createInstance(
162 const uno::Reference<uno::XComponentContext>& rxContext)
163 throw(uno::Exception);
164 extern OUString PresenterCanvas_getImplementationName(void)
165 throw (uno::RuntimeException);
166 extern uno::Sequence<OUString> SAL_CALL PresenterCanvas_getSupportedServiceNames (void)
167 throw (uno::RuntimeException);
168
169 extern uno::Reference<uno::XInterface> SAL_CALL PresenterTextViewService_createInstance(
170 const uno::Reference<uno::XComponentContext>& rxContext)
171 throw(uno::Exception);
172 extern OUString PresenterTextViewService_getImplementationName(void)
173 throw (uno::RuntimeException);
174 extern uno::Sequence<OUString> SAL_CALL PresenterTextViewService_getSupportedServiceNames (void)
175 throw (uno::RuntimeException);
176
177 extern uno::Reference<uno::XInterface> SAL_CALL PresenterHelperService_createInstance(
178 const uno::Reference<uno::XComponentContext>& rxContext)
179 throw(uno::Exception);
180 extern OUString PresenterHelperService_getImplementationName(void)
181 throw (uno::RuntimeException);
182 extern uno::Sequence<OUString> SAL_CALL PresenterHelperService_getSupportedServiceNames (void)
183 throw (uno::RuntimeException);
184
185 extern uno::Reference<uno::XInterface> SAL_CALL PresenterPreviewCache_createInstance(
186 const uno::Reference<uno::XComponentContext>& rxContext)
187 throw(uno::Exception);
188 extern OUString PresenterPreviewCache_getImplementationName(void)
189 throw (uno::RuntimeException);
190 extern uno::Sequence<OUString> SAL_CALL PresenterPreviewCache_getSupportedServiceNames (void)
191 throw (uno::RuntimeException);
192 } }
193
194
195 namespace sd { namespace slidesorter {
196 extern uno::Reference<uno::XInterface> SAL_CALL SlideSorterService_createInstance(
197 const uno::Reference<uno::XComponentContext>& rxContext)
198 throw(uno::Exception);
199 extern OUString SlideSorterService_getImplementationName(void)
200 throw (uno::RuntimeException);
201 extern uno::Sequence<OUString> SAL_CALL SlideSorterService_getSupportedServiceNames (void)
202 throw (uno::RuntimeException);
203 } }
204
205 using namespace ::sd;
206 using namespace ::sd::framework;
207 using namespace ::sd::presenter;
208 using namespace ::sd::slidesorter;
209 using namespace ::sd::sidebar;
210
211
212
213
214 // ----------------------------------------------------------------------------
215 // Declaration and initialization of a map from service names to locally
216 // unique factory identifiers.
217
218 enum FactoryId
219 {
220 SdDrawingDocumentFactoryId,
221 SdPresentationDocumentFactoryId,
222 SdHtmlOptionsDialogFactoryId,
223 SdUnoModuleFactoryId,
224 RandomNodeFactoryId,
225
226 ConfigurationFactoryId,
227 ConfigurationControllerFactoryId,
228 ModuleControllerFactoryId,
229 BasicPaneFactoryFactoryId,
230 BasicToolBarFactoryFactoryId,
231 BasicViewFactoryFactoryId,
232 PanelFactoryFactoryId,
233 ResourceIdFactoryId,
234 PresentationFactoryProviderFactoryId,
235 SlideRendererFactoryId,
236 PresenterCanvasFactoryId,
237 PresenterTextViewServiceFactoryId,
238 PresenterHelperServiceFactoryId,
239 PresenterPreviewCacheFactoryId,
240 SlideSorterServiceFactoryId,
241 SlideLayoutControllerFactoryId,
242 InsertSlideControllerFactoryId,
243 };
244 typedef ::std::hash_map<OUString, FactoryId, comphelper::UStringHash, comphelper::UStringEqual> FactoryMap;
245
246
247 namespace {
248 static ::boost::shared_ptr<FactoryMap> spFactoryMap;
GetFactoryMap(void)249 ::boost::shared_ptr<FactoryMap> GetFactoryMap (void)
250 {
251 if (spFactoryMap.get() == NULL)
252 {
253 spFactoryMap.reset(new FactoryMap);
254 (*spFactoryMap)[SdDrawingDocument_getImplementationName()] = SdDrawingDocumentFactoryId;
255 (*spFactoryMap)[SdPresentationDocument_getImplementationName()] = SdPresentationDocumentFactoryId;
256 (*spFactoryMap)[SdHtmlOptionsDialog_getImplementationName()] = SdHtmlOptionsDialogFactoryId;
257 (*spFactoryMap)[SdUnoModule_getImplementationName()] = SdUnoModuleFactoryId;
258 (*spFactoryMap)[RandomNode__getImplementationName()] = RandomNodeFactoryId;
259 (*spFactoryMap)[Configuration_getImplementationName()] = ConfigurationFactoryId;
260 (*spFactoryMap)[ConfigurationController_getImplementationName()] = ConfigurationControllerFactoryId;
261 (*spFactoryMap)[ModuleController_getImplementationName()] = ModuleControllerFactoryId;
262 (*spFactoryMap)[BasicPaneFactory_getImplementationName()] = BasicPaneFactoryFactoryId;
263 (*spFactoryMap)[BasicToolBarFactory_getImplementationName()] = BasicToolBarFactoryFactoryId;
264 (*spFactoryMap)[BasicViewFactory_getImplementationName()] = BasicViewFactoryFactoryId;
265 (*spFactoryMap)[sidebar::PanelFactory_getImplementationName()] = PanelFactoryFactoryId;
266 (*spFactoryMap)[ResourceId_getImplementationName()] = ResourceIdFactoryId;
267 (*spFactoryMap)[PresentationFactoryProvider_getImplementationName()] = PresentationFactoryProviderFactoryId;
268 (*spFactoryMap)[SlideRenderer_getImplementationName()] = SlideRendererFactoryId;
269 (*spFactoryMap)[PresenterCanvas_getImplementationName()] = PresenterCanvasFactoryId;
270 (*spFactoryMap)[PresenterTextViewService_getImplementationName()] = PresenterTextViewServiceFactoryId;
271 (*spFactoryMap)[PresenterHelperService_getImplementationName()] = PresenterHelperServiceFactoryId;
272 (*spFactoryMap)[PresenterPreviewCache_getImplementationName()] = PresenterPreviewCacheFactoryId;
273 (*spFactoryMap)[SlideSorterService_getImplementationName()] = SlideSorterServiceFactoryId;
274 (*spFactoryMap)[SlideLayoutController_getImplementationName()] = SlideLayoutControllerFactoryId;
275 (*spFactoryMap)[InsertSlideController_getImplementationName()] = InsertSlideControllerFactoryId;
276 }
277 return spFactoryMap;
278 };
279 } // end of anonymous namespace
280
281
282 extern "C"
283 {
284
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)285 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
286 const sal_Char ** ppEnvTypeName,
287 uno_Environment ** )
288 {
289 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
290 }
291
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)292 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
293 const sal_Char * pImplName,
294 void * pServiceManager,
295 void * )
296 {
297 void * pRet = 0;
298
299 if( pServiceManager )
300 {
301 uno::Reference< lang::XMultiServiceFactory > xMSF( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
302
303 uno::Reference<lang::XSingleServiceFactory> xFactory;
304 uno::Reference<lang::XSingleComponentFactory> xComponentFactory;
305
306 ::boost::shared_ptr<FactoryMap> pFactoryMap (GetFactoryMap());
307 OUString sImplementationName (OUString::createFromAscii(pImplName));
308 FactoryMap::const_iterator iFactory (pFactoryMap->find(sImplementationName));
309 if (iFactory != pFactoryMap->end())
310 {
311 switch (iFactory->second)
312 {
313 case SdHtmlOptionsDialogFactoryId:
314 xFactory = ::cppu::createSingleFactory(
315 xMSF,
316 SdHtmlOptionsDialog_getImplementationName(),
317 SdHtmlOptionsDialog_CreateInstance,
318 SdHtmlOptionsDialog_getSupportedServiceNames());
319 break;
320
321 case SdDrawingDocumentFactoryId:
322 xFactory = ::sfx2::createSfxModelFactory(
323 xMSF,
324 SdDrawingDocument_getImplementationName(),
325 SdDrawingDocument_createInstance,
326 SdDrawingDocument_getSupportedServiceNames());
327 break;
328
329 case SdPresentationDocumentFactoryId:
330 xFactory = ::sfx2::createSfxModelFactory(
331 xMSF,
332 SdPresentationDocument_getImplementationName(),
333 SdPresentationDocument_createInstance,
334 SdPresentationDocument_getSupportedServiceNames());
335 break;
336
337 case SdUnoModuleFactoryId:
338 xFactory = ::cppu::createSingleFactory(
339 xMSF,
340 SdUnoModule_getImplementationName(),
341 SdUnoModule_createInstance,
342 SdUnoModule_getSupportedServiceNames());
343 break;
344
345 case RandomNodeFactoryId:
346 xFactory = ::cppu::createSingleFactory(
347 xMSF,
348 sd::RandomNode__getImplementationName(),
349 sd::RandomNode_createInstance,
350 sd::RandomNode_getSupportedServiceNames());
351 break;
352
353 case ConfigurationFactoryId:
354 xComponentFactory = ::cppu::createSingleComponentFactory(
355 sd::framework::Configuration_createInstance,
356 sd::framework::Configuration_getImplementationName(),
357 sd::framework::Configuration_getSupportedServiceNames());
358 break;
359
360 case ConfigurationControllerFactoryId:
361 xComponentFactory = ::cppu::createSingleComponentFactory(
362 sd::framework::ConfigurationController_createInstance,
363 sd::framework::ConfigurationController_getImplementationName(),
364 sd::framework::ConfigurationController_getSupportedServiceNames());
365 break;
366
367 case ModuleControllerFactoryId:
368 xComponentFactory = ::cppu::createSingleComponentFactory(
369 sd::framework::ModuleController_createInstance,
370 sd::framework::ModuleController_getImplementationName(),
371 sd::framework::ModuleController_getSupportedServiceNames());
372 break;
373
374 case BasicPaneFactoryFactoryId:
375 xComponentFactory = ::cppu::createSingleComponentFactory(
376 sd::framework::BasicPaneFactory_createInstance,
377 sd::framework::BasicPaneFactory_getImplementationName(),
378 sd::framework::BasicPaneFactory_getSupportedServiceNames());
379 break;
380
381 case BasicToolBarFactoryFactoryId:
382 xComponentFactory = ::cppu::createSingleComponentFactory(
383 sd::framework::BasicToolBarFactory_createInstance,
384 sd::framework::BasicToolBarFactory_getImplementationName(),
385 sd::framework::BasicToolBarFactory_getSupportedServiceNames());
386 break;
387
388 case BasicViewFactoryFactoryId:
389 xComponentFactory = ::cppu::createSingleComponentFactory(
390 sd::framework::BasicViewFactory_createInstance,
391 sd::framework::BasicViewFactory_getImplementationName(),
392 sd::framework::BasicViewFactory_getSupportedServiceNames());
393 break;
394
395 case PanelFactoryFactoryId:
396 xComponentFactory = ::cppu::createSingleComponentFactory(
397 sd::sidebar::PanelFactory_createInstance,
398 sd::sidebar::PanelFactory_getImplementationName(),
399 sd::sidebar::PanelFactory_getSupportedServiceNames());
400 break;
401
402 case ResourceIdFactoryId:
403 xComponentFactory = ::cppu::createSingleComponentFactory(
404 sd::framework::ResourceId_createInstance,
405 sd::framework::ResourceId_getImplementationName(),
406 sd::framework::ResourceId_getSupportedServiceNames());
407 break;
408
409 case PresentationFactoryProviderFactoryId:
410 xComponentFactory = ::cppu::createSingleComponentFactory(
411 sd::framework::PresentationFactoryProvider_createInstance,
412 sd::framework::PresentationFactoryProvider_getImplementationName(),
413 sd::framework::PresentationFactoryProvider_getSupportedServiceNames());
414 break;
415
416 case SlideRendererFactoryId:
417 xComponentFactory = ::cppu::createSingleComponentFactory(
418 sd::presenter::SlideRenderer_createInstance,
419 sd::presenter::SlideRenderer_getImplementationName(),
420 sd::presenter::SlideRenderer_getSupportedServiceNames());
421 break;
422
423 case PresenterCanvasFactoryId:
424 xComponentFactory = ::cppu::createSingleComponentFactory(
425 sd::presenter::PresenterCanvas_createInstance,
426 sd::presenter::PresenterCanvas_getImplementationName(),
427 sd::presenter::PresenterCanvas_getSupportedServiceNames());
428 break;
429
430 case PresenterTextViewServiceFactoryId:
431 xComponentFactory = ::cppu::createSingleComponentFactory(
432 sd::presenter::PresenterTextViewService_createInstance,
433 sd::presenter::PresenterTextViewService_getImplementationName(),
434 sd::presenter::PresenterTextViewService_getSupportedServiceNames());
435 break;
436
437 case PresenterHelperServiceFactoryId:
438 xComponentFactory = ::cppu::createSingleComponentFactory(
439 sd::presenter::PresenterHelperService_createInstance,
440 sd::presenter::PresenterHelperService_getImplementationName(),
441 sd::presenter::PresenterHelperService_getSupportedServiceNames());
442 break;
443
444 case PresenterPreviewCacheFactoryId:
445 xComponentFactory = ::cppu::createSingleComponentFactory(
446 sd::presenter::PresenterPreviewCache_createInstance,
447 sd::presenter::PresenterPreviewCache_getImplementationName(),
448 sd::presenter::PresenterPreviewCache_getSupportedServiceNames());
449 break;
450
451 case SlideSorterServiceFactoryId:
452 xComponentFactory = ::cppu::createSingleComponentFactory(
453 sd::slidesorter::SlideSorterService_createInstance,
454 sd::slidesorter::SlideSorterService_getImplementationName(),
455 sd::slidesorter::SlideSorterService_getSupportedServiceNames());
456 break;
457
458 case SlideLayoutControllerFactoryId:
459 xFactory = ::cppu::createSingleFactory(
460 xMSF,
461 sd::SlideLayoutController_getImplementationName(),
462 sd::SlideLayoutController_createInstance,
463 sd::SlideLayoutController_getSupportedServiceNames());
464 break;
465
466 case InsertSlideControllerFactoryId:
467 xFactory = ::cppu::createSingleFactory(
468 xMSF,
469 sd::InsertSlideController_getImplementationName(),
470 sd::InsertSlideController_createInstance,
471 sd::InsertSlideController_getSupportedServiceNames());
472 default:
473 break;
474 }
475 if (xComponentFactory.is())
476 {
477 xComponentFactory->acquire();
478 pRet = xComponentFactory.get();
479 }
480 else if (xFactory.is())
481 {
482 xFactory->acquire();
483 pRet = xFactory.get();
484 }
485 }
486 }
487
488 if (pRet != NULL)
489 SdDLL::Init();
490 return pRet;
491 }
492
493 } // end of extern "C"
494