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