1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: register.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_starmath.hxx"
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/registry/XRegistryKey.hpp>
35 #include <com/sun/star/uno/Sequence.h>
36 #include <rtl/ustring.hxx>
38 #include <sfx2/sfxmodelfactory.hxx>
41 #include "document.hxx"
42 #include "unomodel.hxx"
44 using namespace ::rtl
;
45 using namespace ::com::sun::star
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::lang
;
50 extern Sequence
< OUString
> SAL_CALL
51 SmDocument_getSupportedServiceNames() throw();
52 extern OUString SAL_CALL
53 SmDocument_getImplementationName() throw();
54 extern Reference
< XInterface
>SAL_CALL
55 SmDocument_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
, const sal_uInt64 _nCreationFlags
) throw( Exception
);
58 extern Sequence
< OUString
> SAL_CALL
59 SmXMLImport_getSupportedServiceNames() throw();
60 extern OUString SAL_CALL
61 SmXMLImport_getImplementationName() throw();
62 extern Reference
< XInterface
> SAL_CALL
63 SmXMLImport_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
64 extern Sequence
< OUString
> SAL_CALL
65 SmXMLImportMeta_getSupportedServiceNames() throw();
66 extern OUString SAL_CALL
67 SmXMLImportMeta_getImplementationName() throw();
68 extern Reference
< XInterface
> SAL_CALL
69 SmXMLImportMeta_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
70 extern Sequence
< OUString
> SAL_CALL
71 SmXMLImportSettings_getSupportedServiceNames() throw();
72 extern OUString SAL_CALL
SmXMLImportSettings_getImplementationName() throw();
73 extern Reference
< XInterface
> SAL_CALL
74 SmXMLImportSettings_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
77 extern Sequence
< OUString
> SAL_CALL
78 SmXMLExport_getSupportedServiceNames() throw();
79 extern OUString SAL_CALL
80 SmXMLExport_getImplementationName() throw();
81 extern Reference
< XInterface
> SAL_CALL
82 SmXMLExport_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
83 extern Sequence
< OUString
> SAL_CALL
84 SmXMLExportMetaOOO_getSupportedServiceNames() throw();
85 extern OUString SAL_CALL
86 SmXMLExportMetaOOO_getImplementationName() throw();
87 extern Reference
< XInterface
> SAL_CALL
88 SmXMLExportMetaOOO_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
89 extern Sequence
< OUString
> SAL_CALL
90 SmXMLExportMeta_getSupportedServiceNames() throw();
91 extern OUString SAL_CALL
92 SmXMLExportMeta_getImplementationName() throw();
93 extern Reference
< XInterface
> SAL_CALL
94 SmXMLExportMeta_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
95 extern Sequence
< OUString
> SAL_CALL
96 SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
97 extern OUString SAL_CALL
98 SmXMLExportSettingsOOO_getImplementationName() throw();
99 extern Reference
< XInterface
> SAL_CALL
100 SmXMLExportSettingsOOO_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
101 extern Sequence
< OUString
> SAL_CALL
102 SmXMLExportSettings_getSupportedServiceNames() throw();
103 extern OUString SAL_CALL
104 SmXMLExportSettings_getImplementationName() throw();
105 extern Reference
< XInterface
> SAL_CALL
106 SmXMLExportSettings_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
107 extern Sequence
< OUString
> SAL_CALL
108 SmXMLExportContent_getSupportedServiceNames() throw();
109 extern OUString SAL_CALL
110 SmXMLExportContent_getImplementationName() throw();
111 extern Reference
< XInterface
> SAL_CALL
112 SmXMLExportContent_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
117 void SAL_CALL
component_getImplementationEnvironment(
118 const sal_Char
** ppEnvironmentTypeName
,
119 uno_Environment
** /*ppEnvironment*/ )
121 *ppEnvironmentTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
124 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/,
127 Reference
< registry::XRegistryKey
>
128 xKey( reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
) ) ;
130 OUString
aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
131 OUString
aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
133 // Eigentliche Implementierung und ihre Services registrieren
135 Reference
< registry::XRegistryKey
> xNewKey
;
137 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLImport_getImplementationName() +
140 Sequence
< OUString
> aServices
= SmXMLImport_getSupportedServiceNames();
141 for(i
= 0; i
< aServices
.getLength(); i
++ )
142 xNewKey
->createKey( aServices
.getConstArray()[i
] );
144 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLExport_getImplementationName() +
147 aServices
= SmXMLExport_getSupportedServiceNames();
148 for(i
= 0; i
< aServices
.getLength(); i
++ )
149 xNewKey
->createKey( aServices
.getConstArray()[i
] );
151 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLImportMeta_getImplementationName() +
154 aServices
= SmXMLImportMeta_getSupportedServiceNames();
155 for(i
= 0; i
< aServices
.getLength(); i
++ )
156 xNewKey
->createKey( aServices
.getConstArray()[i
] );
158 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLExportMetaOOO_getImplementationName() +
161 aServices
= SmXMLExportMetaOOO_getSupportedServiceNames();
162 for(i
= 0; i
< aServices
.getLength(); i
++ )
163 xNewKey
->createKey( aServices
.getConstArray()[i
] );
165 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLExportMeta_getImplementationName() +
168 aServices
= SmXMLExportMeta_getSupportedServiceNames();
169 for(i
= 0; i
< aServices
.getLength(); i
++ )
170 xNewKey
->createKey( aServices
.getConstArray()[i
] );
172 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLImportSettings_getImplementationName() +
175 aServices
= SmXMLImportSettings_getSupportedServiceNames();
176 for(i
= 0; i
< aServices
.getLength(); i
++ )
177 xNewKey
->createKey( aServices
.getConstArray()[i
] );
179 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLExportSettingsOOO_getImplementationName() +
182 aServices
= SmXMLExportSettingsOOO_getSupportedServiceNames();
183 for(i
= 0; i
< aServices
.getLength(); i
++ )
184 xNewKey
->createKey( aServices
.getConstArray()[i
] );
186 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLExportSettings_getImplementationName() +
189 aServices
= SmXMLExportSettings_getSupportedServiceNames();
190 for(i
= 0; i
< aServices
.getLength(); i
++ )
191 xNewKey
->createKey( aServices
.getConstArray()[i
] );
193 xNewKey
= xKey
->createKey( aDelimiter
+ SmXMLExportContent_getImplementationName() +
196 aServices
= SmXMLExportContent_getSupportedServiceNames();
197 for(i
= 0; i
< aServices
.getLength(); i
++ )
198 xNewKey
->createKey( aServices
.getConstArray()[i
] );
200 xNewKey
= xKey
->createKey( aDelimiter
+ SmDocument_getImplementationName() +
203 aServices
= SmDocument_getSupportedServiceNames();
204 for(i
= 0; i
< aServices
.getLength(); i
++ )
205 xNewKey
->createKey( aServices
.getConstArray()[i
] );
210 void* SAL_CALL
component_getFactory( const sal_Char
* pImplementationName
,
211 void* pServiceManager
,
212 void* /*pRegistryKey*/ )
214 // Set default return value for this operation - if it failed.
215 void* pReturn
= NULL
;
218 ( pImplementationName
!= NULL
) &&
219 ( pServiceManager
!= NULL
)
222 // Define variables which are used in following macros.
223 Reference
< XSingleServiceFactory
> xFactory
;
224 Reference
< XMultiServiceFactory
> xServiceManager( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
226 if( SmXMLImport_getImplementationName().equalsAsciiL(
227 pImplementationName
, strlen(pImplementationName
)) )
229 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
230 SmXMLImport_getImplementationName(),
231 SmXMLImport_createInstance
,
232 SmXMLImport_getSupportedServiceNames() );
234 else if( SmXMLExport_getImplementationName().equalsAsciiL(
235 pImplementationName
, strlen(pImplementationName
)) )
237 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
238 SmXMLExport_getImplementationName(),
239 SmXMLExport_createInstance
,
240 SmXMLExport_getSupportedServiceNames() );
242 else if( SmXMLImportMeta_getImplementationName().equalsAsciiL(
243 pImplementationName
, strlen(pImplementationName
)) )
245 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
246 SmXMLImportMeta_getImplementationName(),
247 SmXMLImportMeta_createInstance
,
248 SmXMLImportMeta_getSupportedServiceNames() );
250 else if( SmXMLExportMetaOOO_getImplementationName().equalsAsciiL(
251 pImplementationName
, strlen(pImplementationName
)) )
253 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
254 SmXMLExportMetaOOO_getImplementationName(),
255 SmXMLExportMetaOOO_createInstance
,
256 SmXMLExportMetaOOO_getSupportedServiceNames() );
258 else if( SmXMLExportMeta_getImplementationName().equalsAsciiL(
259 pImplementationName
, strlen(pImplementationName
)) )
261 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
262 SmXMLExportMeta_getImplementationName(),
263 SmXMLExportMeta_createInstance
,
264 SmXMLExportMeta_getSupportedServiceNames() );
266 else if( SmXMLImportSettings_getImplementationName().equalsAsciiL(
267 pImplementationName
, strlen(pImplementationName
)) )
269 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
270 SmXMLImportSettings_getImplementationName(),
271 SmXMLImportSettings_createInstance
,
272 SmXMLImportSettings_getSupportedServiceNames() );
274 else if( SmXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
275 pImplementationName
, strlen(pImplementationName
)) )
277 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
278 SmXMLExportSettingsOOO_getImplementationName(),
279 SmXMLExportSettingsOOO_createInstance
,
280 SmXMLExportSettingsOOO_getSupportedServiceNames() );
282 else if( SmXMLExportSettings_getImplementationName().equalsAsciiL(
283 pImplementationName
, strlen(pImplementationName
)) )
285 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
286 SmXMLExportSettings_getImplementationName(),
287 SmXMLExportSettings_createInstance
,
288 SmXMLExportSettings_getSupportedServiceNames() );
290 else if( SmXMLExportContent_getImplementationName().equalsAsciiL(
291 pImplementationName
, strlen(pImplementationName
)) )
293 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
294 SmXMLExportContent_getImplementationName(),
295 SmXMLExportContent_createInstance
,
296 SmXMLExportContent_getSupportedServiceNames() );
298 else if( SmDocument_getImplementationName().equalsAsciiL(
299 pImplementationName
, strlen(pImplementationName
)) )
301 xFactory
= ::sfx2::createSfxModelFactory( xServiceManager
,
302 SmDocument_getImplementationName(),
303 SmDocument_createInstance
,
304 SmDocument_getSupportedServiceNames() );
308 // Factory is valid - service was found.
312 pReturn
= xFactory
.get();
316 // Return with result of this operation.