xref: /aoo42x/main/starmath/source/register.cxx (revision b63233d8)
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_starmath.hxx"
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/registry/XRegistryKey.hpp>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <rtl/ustring.hxx>
30 
31 #include <sfx2/sfxmodelfactory.hxx>
32 
33 #include "smdll.hxx"
34 #include "document.hxx"
35 #include "unomodel.hxx"
36 
37 using namespace ::rtl;
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 
42 //Math document
43 extern Sequence< OUString > SAL_CALL
44         SmDocument_getSupportedServiceNames() throw();
45 extern OUString SAL_CALL
46         SmDocument_getImplementationName() throw();
47 extern Reference< XInterface >SAL_CALL
48         SmDocument_createInstance(const Reference< XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags) throw( Exception );
49 
50 //MathML import
51 extern Sequence< OUString > SAL_CALL
52         SmXMLImport_getSupportedServiceNames() throw();
53 extern OUString SAL_CALL
54         SmXMLImport_getImplementationName() throw();
55 extern Reference< XInterface > SAL_CALL
56         SmXMLImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
57 extern Sequence< OUString > SAL_CALL
58         SmXMLImportMeta_getSupportedServiceNames() throw();
59 extern OUString SAL_CALL
60         SmXMLImportMeta_getImplementationName() throw();
61 extern Reference< XInterface > SAL_CALL
62         SmXMLImportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
63 extern Sequence< OUString > SAL_CALL
64         SmXMLImportSettings_getSupportedServiceNames() throw();
65 extern OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw();
66 extern Reference< XInterface > SAL_CALL
67         SmXMLImportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
68 
69 //MathML export
70 extern Sequence< OUString > SAL_CALL
71         SmXMLExport_getSupportedServiceNames() throw();
72 extern OUString SAL_CALL
73         SmXMLExport_getImplementationName() throw();
74 extern Reference< XInterface > SAL_CALL
75         SmXMLExport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
76 extern Sequence< OUString > SAL_CALL
77         SmXMLExportMetaOOO_getSupportedServiceNames() throw();
78 extern OUString SAL_CALL
79         SmXMLExportMetaOOO_getImplementationName() throw();
80 extern Reference< XInterface > SAL_CALL
81         SmXMLExportMetaOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
82 extern Sequence< OUString > SAL_CALL
83         SmXMLExportMeta_getSupportedServiceNames() throw();
84 extern OUString SAL_CALL
85         SmXMLExportMeta_getImplementationName() throw();
86 extern Reference< XInterface > SAL_CALL
87         SmXMLExportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
88 extern Sequence< OUString > SAL_CALL
89         SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
90 extern OUString SAL_CALL
91         SmXMLExportSettingsOOO_getImplementationName() throw();
92 extern Reference< XInterface > SAL_CALL
93         SmXMLExportSettingsOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
94 extern Sequence< OUString > SAL_CALL
95         SmXMLExportSettings_getSupportedServiceNames() throw();
96 extern OUString SAL_CALL
97         SmXMLExportSettings_getImplementationName() throw();
98 extern Reference< XInterface > SAL_CALL
99         SmXMLExportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
100 extern Sequence< OUString > SAL_CALL
101         SmXMLExportContent_getSupportedServiceNames() throw();
102 extern OUString SAL_CALL
103         SmXMLExportContent_getImplementationName() throw();
104 extern Reference< XInterface > SAL_CALL
105         SmXMLExportContent_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
106 
107 
108 extern "C" {
109 
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment **)110 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
111         const  sal_Char**   ppEnvironmentTypeName,
112         uno_Environment**   /*ppEnvironment*/  )
113 {
114 	*ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
115 }
116 
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)117 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
118                                      void* pServiceManager,
119                                      void* /*pRegistryKey*/ )
120 {
121 	// Set default return value for this operation - if it failed.
122 	void* pReturn = NULL ;
123 
124 	if	(
125 			( pImplementationName	!=	NULL ) &&
126 			( pServiceManager		!=	NULL )
127 		)
128 	{
129 		// Define variables which are used in following macros.
130         Reference< XSingleServiceFactory >   xFactory                                                                                                ;
131         Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
132 
133 		if( SmXMLImport_getImplementationName().equalsAsciiL(
134 			pImplementationName, strlen(pImplementationName)) )
135 		{
136 			xFactory = ::cppu::createSingleFactory( xServiceManager,
137 			SmXMLImport_getImplementationName(),
138 			SmXMLImport_createInstance,
139 			SmXMLImport_getSupportedServiceNames() );
140 		}
141 		else if( SmXMLExport_getImplementationName().equalsAsciiL(
142 			pImplementationName, strlen(pImplementationName)) )
143 		{
144 			xFactory = ::cppu::createSingleFactory( xServiceManager,
145 			SmXMLExport_getImplementationName(),
146 			SmXMLExport_createInstance,
147 			SmXMLExport_getSupportedServiceNames() );
148 		}
149 		else if( SmXMLImportMeta_getImplementationName().equalsAsciiL(
150 			pImplementationName, strlen(pImplementationName)) )
151 		{
152 			xFactory = ::cppu::createSingleFactory( xServiceManager,
153 			SmXMLImportMeta_getImplementationName(),
154 			SmXMLImportMeta_createInstance,
155 			SmXMLImportMeta_getSupportedServiceNames() );
156 		}
157 		else if( SmXMLExportMetaOOO_getImplementationName().equalsAsciiL(
158 			pImplementationName, strlen(pImplementationName)) )
159 		{
160 			xFactory = ::cppu::createSingleFactory( xServiceManager,
161 			SmXMLExportMetaOOO_getImplementationName(),
162 			SmXMLExportMetaOOO_createInstance,
163 			SmXMLExportMetaOOO_getSupportedServiceNames() );
164 		}
165 		else if( SmXMLExportMeta_getImplementationName().equalsAsciiL(
166 			pImplementationName, strlen(pImplementationName)) )
167 		{
168 			xFactory = ::cppu::createSingleFactory( xServiceManager,
169 			SmXMLExportMeta_getImplementationName(),
170 			SmXMLExportMeta_createInstance,
171 			SmXMLExportMeta_getSupportedServiceNames() );
172 		}
173 		else if( SmXMLImportSettings_getImplementationName().equalsAsciiL(
174 			pImplementationName, strlen(pImplementationName)) )
175 		{
176 			xFactory = ::cppu::createSingleFactory( xServiceManager,
177 			SmXMLImportSettings_getImplementationName(),
178 			SmXMLImportSettings_createInstance,
179 			SmXMLImportSettings_getSupportedServiceNames() );
180 		}
181 		else if( SmXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
182 			pImplementationName, strlen(pImplementationName)) )
183 		{
184 			xFactory = ::cppu::createSingleFactory( xServiceManager,
185 			SmXMLExportSettingsOOO_getImplementationName(),
186 			SmXMLExportSettingsOOO_createInstance,
187 			SmXMLExportSettingsOOO_getSupportedServiceNames() );
188 		}
189 		else if( SmXMLExportSettings_getImplementationName().equalsAsciiL(
190 			pImplementationName, strlen(pImplementationName)) )
191 		{
192 			xFactory = ::cppu::createSingleFactory( xServiceManager,
193 			SmXMLExportSettings_getImplementationName(),
194 			SmXMLExportSettings_createInstance,
195 			SmXMLExportSettings_getSupportedServiceNames() );
196 		}
197 	    else if( SmXMLExportContent_getImplementationName().equalsAsciiL(
198 			pImplementationName, strlen(pImplementationName)) )
199 		{
200 			xFactory = ::cppu::createSingleFactory( xServiceManager,
201 			SmXMLExportContent_getImplementationName(),
202 			SmXMLExportContent_createInstance,
203 			SmXMLExportContent_getSupportedServiceNames() );
204 		}
205 	    else if( SmDocument_getImplementationName().equalsAsciiL(
206 			pImplementationName, strlen(pImplementationName)) )
207 		{
208 			xFactory = ::sfx2::createSfxModelFactory( xServiceManager,
209 			SmDocument_getImplementationName(),
210 			SmDocument_createInstance,
211 			SmDocument_getSupportedServiceNames() );
212 		}
213 
214 
215 		// Factory is valid - service was found.
216 		if ( xFactory.is() )
217 		{
218 			xFactory->acquire();
219 			pReturn = xFactory.get();
220 		}
221 	}
222 
223 	// Return with result of this operation.
224 	return pReturn ;
225 }
226 } // extern "C"
227 
228 
229 
230