xref: /AOO41X/main/starmath/source/register.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_starmath.hxx"
30*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
33*cdf0e10cSrcweir #include <rtl/ustring.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <sfx2/sfxmodelfactory.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "smdll.hxx"
38*cdf0e10cSrcweir #include "document.hxx"
39*cdf0e10cSrcweir #include "unomodel.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir using namespace ::rtl;
42*cdf0e10cSrcweir using namespace ::com::sun::star;
43*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //Math document
47*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
48*cdf0e10cSrcweir         SmDocument_getSupportedServiceNames() throw();
49*cdf0e10cSrcweir extern OUString SAL_CALL
50*cdf0e10cSrcweir         SmDocument_getImplementationName() throw();
51*cdf0e10cSrcweir extern Reference< XInterface >SAL_CALL
52*cdf0e10cSrcweir         SmDocument_createInstance(const Reference< XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags) throw( Exception );
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //MathML import
55*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
56*cdf0e10cSrcweir         SmXMLImport_getSupportedServiceNames() throw();
57*cdf0e10cSrcweir extern OUString SAL_CALL
58*cdf0e10cSrcweir         SmXMLImport_getImplementationName() throw();
59*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
60*cdf0e10cSrcweir         SmXMLImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
61*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
62*cdf0e10cSrcweir         SmXMLImportMeta_getSupportedServiceNames() throw();
63*cdf0e10cSrcweir extern OUString SAL_CALL
64*cdf0e10cSrcweir         SmXMLImportMeta_getImplementationName() throw();
65*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
66*cdf0e10cSrcweir         SmXMLImportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
67*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
68*cdf0e10cSrcweir         SmXMLImportSettings_getSupportedServiceNames() throw();
69*cdf0e10cSrcweir extern OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw();
70*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
71*cdf0e10cSrcweir         SmXMLImportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir //MathML export
74*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
75*cdf0e10cSrcweir         SmXMLExport_getSupportedServiceNames() throw();
76*cdf0e10cSrcweir extern OUString SAL_CALL
77*cdf0e10cSrcweir         SmXMLExport_getImplementationName() throw();
78*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
79*cdf0e10cSrcweir         SmXMLExport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
80*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
81*cdf0e10cSrcweir         SmXMLExportMetaOOO_getSupportedServiceNames() throw();
82*cdf0e10cSrcweir extern OUString SAL_CALL
83*cdf0e10cSrcweir         SmXMLExportMetaOOO_getImplementationName() throw();
84*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
85*cdf0e10cSrcweir         SmXMLExportMetaOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
86*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
87*cdf0e10cSrcweir         SmXMLExportMeta_getSupportedServiceNames() throw();
88*cdf0e10cSrcweir extern OUString SAL_CALL
89*cdf0e10cSrcweir         SmXMLExportMeta_getImplementationName() throw();
90*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
91*cdf0e10cSrcweir         SmXMLExportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
92*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
93*cdf0e10cSrcweir         SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
94*cdf0e10cSrcweir extern OUString SAL_CALL
95*cdf0e10cSrcweir         SmXMLExportSettingsOOO_getImplementationName() throw();
96*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
97*cdf0e10cSrcweir         SmXMLExportSettingsOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
98*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
99*cdf0e10cSrcweir         SmXMLExportSettings_getSupportedServiceNames() throw();
100*cdf0e10cSrcweir extern OUString SAL_CALL
101*cdf0e10cSrcweir         SmXMLExportSettings_getImplementationName() throw();
102*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
103*cdf0e10cSrcweir         SmXMLExportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
104*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
105*cdf0e10cSrcweir         SmXMLExportContent_getSupportedServiceNames() throw();
106*cdf0e10cSrcweir extern OUString SAL_CALL
107*cdf0e10cSrcweir         SmXMLExportContent_getImplementationName() throw();
108*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
109*cdf0e10cSrcweir         SmXMLExportContent_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir extern "C" {
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment(
115*cdf0e10cSrcweir         const  sal_Char**   ppEnvironmentTypeName,
116*cdf0e10cSrcweir         uno_Environment**   /*ppEnvironment*/  )
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir 	*ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
122*cdf0e10cSrcweir                                      void* pServiceManager,
123*cdf0e10cSrcweir                                      void* /*pRegistryKey*/ )
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	// Set default return value for this operation - if it failed.
126*cdf0e10cSrcweir 	void* pReturn = NULL ;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	if	(
129*cdf0e10cSrcweir 			( pImplementationName	!=	NULL ) &&
130*cdf0e10cSrcweir 			( pServiceManager		!=	NULL )
131*cdf0e10cSrcweir 		)
132*cdf0e10cSrcweir 	{
133*cdf0e10cSrcweir 		// Define variables which are used in following macros.
134*cdf0e10cSrcweir         Reference< XSingleServiceFactory >   xFactory                                                                                                ;
135*cdf0e10cSrcweir         Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 		if( SmXMLImport_getImplementationName().equalsAsciiL(
138*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
139*cdf0e10cSrcweir 		{
140*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
141*cdf0e10cSrcweir 			SmXMLImport_getImplementationName(),
142*cdf0e10cSrcweir 			SmXMLImport_createInstance,
143*cdf0e10cSrcweir 			SmXMLImport_getSupportedServiceNames() );
144*cdf0e10cSrcweir 		}
145*cdf0e10cSrcweir 		else if( SmXMLExport_getImplementationName().equalsAsciiL(
146*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
147*cdf0e10cSrcweir 		{
148*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
149*cdf0e10cSrcweir 			SmXMLExport_getImplementationName(),
150*cdf0e10cSrcweir 			SmXMLExport_createInstance,
151*cdf0e10cSrcweir 			SmXMLExport_getSupportedServiceNames() );
152*cdf0e10cSrcweir 		}
153*cdf0e10cSrcweir 		else if( SmXMLImportMeta_getImplementationName().equalsAsciiL(
154*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
155*cdf0e10cSrcweir 		{
156*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
157*cdf0e10cSrcweir 			SmXMLImportMeta_getImplementationName(),
158*cdf0e10cSrcweir 			SmXMLImportMeta_createInstance,
159*cdf0e10cSrcweir 			SmXMLImportMeta_getSupportedServiceNames() );
160*cdf0e10cSrcweir 		}
161*cdf0e10cSrcweir 		else if( SmXMLExportMetaOOO_getImplementationName().equalsAsciiL(
162*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
163*cdf0e10cSrcweir 		{
164*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
165*cdf0e10cSrcweir 			SmXMLExportMetaOOO_getImplementationName(),
166*cdf0e10cSrcweir 			SmXMLExportMetaOOO_createInstance,
167*cdf0e10cSrcweir 			SmXMLExportMetaOOO_getSupportedServiceNames() );
168*cdf0e10cSrcweir 		}
169*cdf0e10cSrcweir 		else if( SmXMLExportMeta_getImplementationName().equalsAsciiL(
170*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
173*cdf0e10cSrcweir 			SmXMLExportMeta_getImplementationName(),
174*cdf0e10cSrcweir 			SmXMLExportMeta_createInstance,
175*cdf0e10cSrcweir 			SmXMLExportMeta_getSupportedServiceNames() );
176*cdf0e10cSrcweir 		}
177*cdf0e10cSrcweir 		else if( SmXMLImportSettings_getImplementationName().equalsAsciiL(
178*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
179*cdf0e10cSrcweir 		{
180*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
181*cdf0e10cSrcweir 			SmXMLImportSettings_getImplementationName(),
182*cdf0e10cSrcweir 			SmXMLImportSettings_createInstance,
183*cdf0e10cSrcweir 			SmXMLImportSettings_getSupportedServiceNames() );
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 		else if( SmXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
186*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
187*cdf0e10cSrcweir 		{
188*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
189*cdf0e10cSrcweir 			SmXMLExportSettingsOOO_getImplementationName(),
190*cdf0e10cSrcweir 			SmXMLExportSettingsOOO_createInstance,
191*cdf0e10cSrcweir 			SmXMLExportSettingsOOO_getSupportedServiceNames() );
192*cdf0e10cSrcweir 		}
193*cdf0e10cSrcweir 		else if( SmXMLExportSettings_getImplementationName().equalsAsciiL(
194*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
195*cdf0e10cSrcweir 		{
196*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
197*cdf0e10cSrcweir 			SmXMLExportSettings_getImplementationName(),
198*cdf0e10cSrcweir 			SmXMLExportSettings_createInstance,
199*cdf0e10cSrcweir 			SmXMLExportSettings_getSupportedServiceNames() );
200*cdf0e10cSrcweir 		}
201*cdf0e10cSrcweir 	    else if( SmXMLExportContent_getImplementationName().equalsAsciiL(
202*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
203*cdf0e10cSrcweir 		{
204*cdf0e10cSrcweir 			xFactory = ::cppu::createSingleFactory( xServiceManager,
205*cdf0e10cSrcweir 			SmXMLExportContent_getImplementationName(),
206*cdf0e10cSrcweir 			SmXMLExportContent_createInstance,
207*cdf0e10cSrcweir 			SmXMLExportContent_getSupportedServiceNames() );
208*cdf0e10cSrcweir 		}
209*cdf0e10cSrcweir 	    else if( SmDocument_getImplementationName().equalsAsciiL(
210*cdf0e10cSrcweir 			pImplementationName, strlen(pImplementationName)) )
211*cdf0e10cSrcweir 		{
212*cdf0e10cSrcweir 			xFactory = ::sfx2::createSfxModelFactory( xServiceManager,
213*cdf0e10cSrcweir 			SmDocument_getImplementationName(),
214*cdf0e10cSrcweir 			SmDocument_createInstance,
215*cdf0e10cSrcweir 			SmDocument_getSupportedServiceNames() );
216*cdf0e10cSrcweir 		}
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 		// Factory is valid - service was found.
220*cdf0e10cSrcweir 		if ( xFactory.is() )
221*cdf0e10cSrcweir 		{
222*cdf0e10cSrcweir 			xFactory->acquire();
223*cdf0e10cSrcweir 			pReturn = xFactory.get();
224*cdf0e10cSrcweir 		}
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	// Return with result of this operation.
228*cdf0e10cSrcweir 	return pReturn ;
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir } // extern "C"
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 
234