xref: /trunk/main/starmath/source/register.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1d107581fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d107581fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d107581fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d107581fSAndrew Rist  * distributed with this work for additional information
6d107581fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d107581fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d107581fSAndrew Rist  * "License"); you may not use this file except in compliance
9d107581fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11d107581fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13d107581fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d107581fSAndrew Rist  * software distributed under the License is distributed on an
15d107581fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d107581fSAndrew Rist  * KIND, either express or implied.  See the License for the
17d107581fSAndrew Rist  * specific language governing permissions and limitations
18d107581fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20d107581fSAndrew Rist  *************************************************************/
21d107581fSAndrew Rist 
22d107581fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_starmath.hxx"
26cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
27cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
28cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
29cdf0e10cSrcweir #include <rtl/ustring.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <sfx2/sfxmodelfactory.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "smdll.hxx"
34cdf0e10cSrcweir #include "document.hxx"
35cdf0e10cSrcweir #include "unomodel.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace ::rtl;
38cdf0e10cSrcweir using namespace ::com::sun::star;
39cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40cdf0e10cSrcweir using namespace ::com::sun::star::lang;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //Math document
43cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
44cdf0e10cSrcweir         SmDocument_getSupportedServiceNames() throw();
45cdf0e10cSrcweir extern OUString SAL_CALL
46cdf0e10cSrcweir         SmDocument_getImplementationName() throw();
47cdf0e10cSrcweir extern Reference< XInterface >SAL_CALL
48cdf0e10cSrcweir         SmDocument_createInstance(const Reference< XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags) throw( Exception );
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //MathML import
51cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
52cdf0e10cSrcweir         SmXMLImport_getSupportedServiceNames() throw();
53cdf0e10cSrcweir extern OUString SAL_CALL
54cdf0e10cSrcweir         SmXMLImport_getImplementationName() throw();
55cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
56cdf0e10cSrcweir         SmXMLImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
57cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
58cdf0e10cSrcweir         SmXMLImportMeta_getSupportedServiceNames() throw();
59cdf0e10cSrcweir extern OUString SAL_CALL
60cdf0e10cSrcweir         SmXMLImportMeta_getImplementationName() throw();
61cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
62cdf0e10cSrcweir         SmXMLImportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
63cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
64cdf0e10cSrcweir         SmXMLImportSettings_getSupportedServiceNames() throw();
65cdf0e10cSrcweir extern OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw();
66cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
67cdf0e10cSrcweir         SmXMLImportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //MathML export
70cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
71cdf0e10cSrcweir         SmXMLExport_getSupportedServiceNames() throw();
72cdf0e10cSrcweir extern OUString SAL_CALL
73cdf0e10cSrcweir         SmXMLExport_getImplementationName() throw();
74cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
75cdf0e10cSrcweir         SmXMLExport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
76cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
77cdf0e10cSrcweir         SmXMLExportMetaOOO_getSupportedServiceNames() throw();
78cdf0e10cSrcweir extern OUString SAL_CALL
79cdf0e10cSrcweir         SmXMLExportMetaOOO_getImplementationName() throw();
80cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
81cdf0e10cSrcweir         SmXMLExportMetaOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
82cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
83cdf0e10cSrcweir         SmXMLExportMeta_getSupportedServiceNames() throw();
84cdf0e10cSrcweir extern OUString SAL_CALL
85cdf0e10cSrcweir         SmXMLExportMeta_getImplementationName() throw();
86cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
87cdf0e10cSrcweir         SmXMLExportMeta_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
88cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
89cdf0e10cSrcweir         SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
90cdf0e10cSrcweir extern OUString SAL_CALL
91cdf0e10cSrcweir         SmXMLExportSettingsOOO_getImplementationName() throw();
92cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
93cdf0e10cSrcweir         SmXMLExportSettingsOOO_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
94cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
95cdf0e10cSrcweir         SmXMLExportSettings_getSupportedServiceNames() throw();
96cdf0e10cSrcweir extern OUString SAL_CALL
97cdf0e10cSrcweir         SmXMLExportSettings_getImplementationName() throw();
98cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
99cdf0e10cSrcweir         SmXMLExportSettings_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
100cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL
101cdf0e10cSrcweir         SmXMLExportContent_getSupportedServiceNames() throw();
102cdf0e10cSrcweir extern OUString SAL_CALL
103cdf0e10cSrcweir         SmXMLExportContent_getImplementationName() throw();
104cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL
105cdf0e10cSrcweir         SmXMLExportContent_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir extern "C" {
109cdf0e10cSrcweir 
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment **)110*b63233d8Sdamjan SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
111cdf0e10cSrcweir         const  sal_Char**   ppEnvironmentTypeName,
112cdf0e10cSrcweir         uno_Environment**   /*ppEnvironment*/  )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)117*b63233d8Sdamjan SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
118cdf0e10cSrcweir                                      void* pServiceManager,
119cdf0e10cSrcweir                                      void* /*pRegistryKey*/ )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     // Set default return value for this operation - if it failed.
122cdf0e10cSrcweir     void* pReturn = NULL ;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     if  (
125cdf0e10cSrcweir             ( pImplementationName   !=  NULL ) &&
126cdf0e10cSrcweir             ( pServiceManager       !=  NULL )
127cdf0e10cSrcweir         )
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir         // Define variables which are used in following macros.
130cdf0e10cSrcweir         Reference< XSingleServiceFactory >   xFactory                                                                                                ;
131cdf0e10cSrcweir         Reference< XMultiServiceFactory >    xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         if( SmXMLImport_getImplementationName().equalsAsciiL(
134cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
137cdf0e10cSrcweir             SmXMLImport_getImplementationName(),
138cdf0e10cSrcweir             SmXMLImport_createInstance,
139cdf0e10cSrcweir             SmXMLImport_getSupportedServiceNames() );
140cdf0e10cSrcweir         }
141cdf0e10cSrcweir         else if( SmXMLExport_getImplementationName().equalsAsciiL(
142cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
143cdf0e10cSrcweir         {
144cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
145cdf0e10cSrcweir             SmXMLExport_getImplementationName(),
146cdf0e10cSrcweir             SmXMLExport_createInstance,
147cdf0e10cSrcweir             SmXMLExport_getSupportedServiceNames() );
148cdf0e10cSrcweir         }
149cdf0e10cSrcweir         else if( SmXMLImportMeta_getImplementationName().equalsAsciiL(
150cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
151cdf0e10cSrcweir         {
152cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
153cdf0e10cSrcweir             SmXMLImportMeta_getImplementationName(),
154cdf0e10cSrcweir             SmXMLImportMeta_createInstance,
155cdf0e10cSrcweir             SmXMLImportMeta_getSupportedServiceNames() );
156cdf0e10cSrcweir         }
157cdf0e10cSrcweir         else if( SmXMLExportMetaOOO_getImplementationName().equalsAsciiL(
158cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
159cdf0e10cSrcweir         {
160cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
161cdf0e10cSrcweir             SmXMLExportMetaOOO_getImplementationName(),
162cdf0e10cSrcweir             SmXMLExportMetaOOO_createInstance,
163cdf0e10cSrcweir             SmXMLExportMetaOOO_getSupportedServiceNames() );
164cdf0e10cSrcweir         }
165cdf0e10cSrcweir         else if( SmXMLExportMeta_getImplementationName().equalsAsciiL(
166cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
167cdf0e10cSrcweir         {
168cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
169cdf0e10cSrcweir             SmXMLExportMeta_getImplementationName(),
170cdf0e10cSrcweir             SmXMLExportMeta_createInstance,
171cdf0e10cSrcweir             SmXMLExportMeta_getSupportedServiceNames() );
172cdf0e10cSrcweir         }
173cdf0e10cSrcweir         else if( SmXMLImportSettings_getImplementationName().equalsAsciiL(
174cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
175cdf0e10cSrcweir         {
176cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
177cdf0e10cSrcweir             SmXMLImportSettings_getImplementationName(),
178cdf0e10cSrcweir             SmXMLImportSettings_createInstance,
179cdf0e10cSrcweir             SmXMLImportSettings_getSupportedServiceNames() );
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir         else if( SmXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
182cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
183cdf0e10cSrcweir         {
184cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
185cdf0e10cSrcweir             SmXMLExportSettingsOOO_getImplementationName(),
186cdf0e10cSrcweir             SmXMLExportSettingsOOO_createInstance,
187cdf0e10cSrcweir             SmXMLExportSettingsOOO_getSupportedServiceNames() );
188cdf0e10cSrcweir         }
189cdf0e10cSrcweir         else if( SmXMLExportSettings_getImplementationName().equalsAsciiL(
190cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
191cdf0e10cSrcweir         {
192cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
193cdf0e10cSrcweir             SmXMLExportSettings_getImplementationName(),
194cdf0e10cSrcweir             SmXMLExportSettings_createInstance,
195cdf0e10cSrcweir             SmXMLExportSettings_getSupportedServiceNames() );
196cdf0e10cSrcweir         }
197cdf0e10cSrcweir         else if( SmXMLExportContent_getImplementationName().equalsAsciiL(
198cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
199cdf0e10cSrcweir         {
200cdf0e10cSrcweir             xFactory = ::cppu::createSingleFactory( xServiceManager,
201cdf0e10cSrcweir             SmXMLExportContent_getImplementationName(),
202cdf0e10cSrcweir             SmXMLExportContent_createInstance,
203cdf0e10cSrcweir             SmXMLExportContent_getSupportedServiceNames() );
204cdf0e10cSrcweir         }
205cdf0e10cSrcweir         else if( SmDocument_getImplementationName().equalsAsciiL(
206cdf0e10cSrcweir             pImplementationName, strlen(pImplementationName)) )
207cdf0e10cSrcweir         {
208cdf0e10cSrcweir             xFactory = ::sfx2::createSfxModelFactory( xServiceManager,
209cdf0e10cSrcweir             SmDocument_getImplementationName(),
210cdf0e10cSrcweir             SmDocument_createInstance,
211cdf0e10cSrcweir             SmDocument_getSupportedServiceNames() );
212cdf0e10cSrcweir         }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         // Factory is valid - service was found.
216cdf0e10cSrcweir         if ( xFactory.is() )
217cdf0e10cSrcweir         {
218cdf0e10cSrcweir             xFactory->acquire();
219cdf0e10cSrcweir             pReturn = xFactory.get();
220cdf0e10cSrcweir         }
221cdf0e10cSrcweir     }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     // Return with result of this operation.
224cdf0e10cSrcweir     return pReturn ;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir } // extern "C"
227