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 <string.h>
21 : #include <com/sun/star/registry/XRegistryKey.hpp>
22 : #include <cppuhelper/factory.hxx>
23 :
24 : #include <XMLFilterRegistration.hxx>
25 :
26 : using namespace ::com::sun::star;
27 :
28 : #define ENUMERATE_SERVICE( classname ) \
29 : { classname##_getImplementationName, classname##_getSupportedServiceNames, classname##_createInstance }
30 :
31 : namespace
32 : {
33 : typedef OUString (SAL_CALL * GetImplementationName)();
34 : typedef uno::Sequence< OUString > (SAL_CALL * GetSupportedServiceNames)();
35 : typedef uno::Reference< ::uno::XInterface > (SAL_CALL * CreateInstance)(
36 : const uno::Reference< lang::XMultiServiceFactory >& );
37 :
38 : struct ServiceDescriptor
39 : {
40 : GetImplementationName getImplementationName;
41 : GetSupportedServiceNames getSupportedServiceNames;
42 : CreateInstance createInstance;
43 : };
44 :
45 0 : static const ServiceDescriptor* getServiceDescriptors()
46 : {
47 : static const ServiceDescriptor aDescriptors[] =
48 : {
49 : ENUMERATE_SERVICE( OOo2OasisTransformer ),
50 : ENUMERATE_SERVICE( Oasis2OOoTransformer ),
51 :
52 : ENUMERATE_SERVICE( XMLAutoTextEventImportOOO ),
53 : ENUMERATE_SERVICE( XMLMetaImportOOO ),
54 : ENUMERATE_SERVICE( XMLMathSettingsImportOOO ),
55 : ENUMERATE_SERVICE( XMLMathMetaImportOOO ),
56 : ENUMERATE_SERVICE( XMLCalcSettingsImportOOO ),
57 : ENUMERATE_SERVICE( XMLCalcMetaImportOOO ),
58 : ENUMERATE_SERVICE( XMLCalcContentImportOOO ),
59 : ENUMERATE_SERVICE( XMLCalcStylesImportOOO ),
60 : ENUMERATE_SERVICE( XMLCalcImportOOO ),
61 : ENUMERATE_SERVICE( XMLWriterSettingsImportOOO ),
62 : ENUMERATE_SERVICE( XMLWriterMetaImportOOO ),
63 : ENUMERATE_SERVICE( XMLWriterContentImportOOO ),
64 : ENUMERATE_SERVICE( XMLWriterStylesImportOOO ),
65 : ENUMERATE_SERVICE( XMLWriterImportOOO ),
66 : ENUMERATE_SERVICE( XMLChartContentImportOOO ),
67 : ENUMERATE_SERVICE( XMLChartStylesImportOOO ),
68 : ENUMERATE_SERVICE( XMLChartImportOOO ),
69 : ENUMERATE_SERVICE( XMLDrawSettingsImportOOO ),
70 : ENUMERATE_SERVICE( XMLDrawMetaImportOOO ),
71 : ENUMERATE_SERVICE( XMLDrawContentImportOOO ),
72 : ENUMERATE_SERVICE( XMLDrawStylesImportOOO ),
73 : ENUMERATE_SERVICE( XMLDrawImportOOO ),
74 : ENUMERATE_SERVICE( XMLImpressSettingsImportOOO ),
75 : ENUMERATE_SERVICE( XMLImpressMetaImportOOO ),
76 : ENUMERATE_SERVICE( XMLImpressContentImportOOO ),
77 : ENUMERATE_SERVICE( XMLImpressStylesImportOOO ),
78 : ENUMERATE_SERVICE( XMLImpressImportOOO ),
79 : { NULL, NULL, NULL }
80 : };
81 0 : return aDescriptors;
82 : };
83 : }
84 :
85 : #ifdef __cplusplus
86 : extern "C"
87 : {
88 : #endif
89 :
90 0 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL xof_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
91 : {
92 0 : void * pRet = NULL;
93 0 : if( pServiceManager )
94 : {
95 : try
96 : {
97 0 : uno::Reference< lang::XMultiServiceFactory > xMSF( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
98 :
99 0 : const sal_Int32 nImplNameLen = strlen( pImplName );
100 :
101 0 : const ServiceDescriptor* pDescriptor = getServiceDescriptors();
102 0 : while ( pDescriptor->getImplementationName )
103 : {
104 0 : if ( pDescriptor->getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) )
105 : {
106 : uno::Reference< lang::XSingleServiceFactory > xFactory =
107 : ::cppu::createSingleFactory( xMSF,
108 : pDescriptor->getImplementationName(),
109 : pDescriptor->createInstance,
110 : pDescriptor->getSupportedServiceNames()
111 0 : );
112 :
113 0 : if ( xFactory.is() )
114 : {
115 0 : xFactory->acquire();
116 0 : pRet = xFactory.get();
117 0 : break;
118 0 : }
119 : }
120 :
121 0 : ++pDescriptor;
122 0 : }
123 : }
124 0 : catch( uno::Exception& )
125 : {
126 : OSL_FAIL( "xof::xof_component_getFactory: Exception!" );
127 : }
128 : }
129 :
130 0 : return pRet;
131 : }
132 :
133 : #ifdef __cplusplus
134 : }
135 : #endif
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|