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