1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XServiceInfo.hpp>
21 #include <com/sun/star/registry/XRegistryKey.hpp>
22 #include <com/sun/star/uno/Sequence.h>
23 #include <rtl/ustring.hxx>
25 #include <sfx2/sfxmodelfactory.hxx>
28 #include "document.hxx"
29 #include "unomodel.hxx"
31 using namespace ::com::sun::star
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::lang
;
36 extern Sequence
< OUString
> SAL_CALL
37 SmDocument_getSupportedServiceNames() throw();
38 extern OUString SAL_CALL
39 SmDocument_getImplementationName() throw();
40 extern Reference
< XInterface
>SAL_CALL
41 SmDocument_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
, const sal_uInt64 _nCreationFlags
) throw( Exception
);
44 extern Sequence
< OUString
> SAL_CALL
45 SmXMLImport_getSupportedServiceNames() throw();
46 extern OUString SAL_CALL
47 SmXMLImport_getImplementationName() throw();
48 extern Reference
< XInterface
> SAL_CALL
49 SmXMLImport_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
50 extern Sequence
< OUString
> SAL_CALL
51 SmXMLImportMeta_getSupportedServiceNames() throw();
52 extern OUString SAL_CALL
53 SmXMLImportMeta_getImplementationName() throw();
54 extern Reference
< XInterface
> SAL_CALL
55 SmXMLImportMeta_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
56 extern Sequence
< OUString
> SAL_CALL
57 SmXMLImportSettings_getSupportedServiceNames() throw();
58 extern OUString SAL_CALL
SmXMLImportSettings_getImplementationName() throw();
59 extern Reference
< XInterface
> SAL_CALL
60 SmXMLImportSettings_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
63 extern Sequence
< OUString
> SAL_CALL
64 SmXMLExport_getSupportedServiceNames() throw();
65 extern OUString SAL_CALL
66 SmXMLExport_getImplementationName() throw();
67 extern Reference
< XInterface
> SAL_CALL
68 SmXMLExport_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
69 extern Sequence
< OUString
> SAL_CALL
70 SmXMLExportMetaOOO_getSupportedServiceNames() throw();
71 extern OUString SAL_CALL
72 SmXMLExportMetaOOO_getImplementationName() throw();
73 extern Reference
< XInterface
> SAL_CALL
74 SmXMLExportMetaOOO_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
75 extern Sequence
< OUString
> SAL_CALL
76 SmXMLExportMeta_getSupportedServiceNames() throw();
77 extern OUString SAL_CALL
78 SmXMLExportMeta_getImplementationName() throw();
79 extern Reference
< XInterface
> SAL_CALL
80 SmXMLExportMeta_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
81 extern Sequence
< OUString
> SAL_CALL
82 SmXMLExportSettingsOOO_getSupportedServiceNames() throw();
83 extern OUString SAL_CALL
84 SmXMLExportSettingsOOO_getImplementationName() throw();
85 extern Reference
< XInterface
> SAL_CALL
86 SmXMLExportSettingsOOO_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
87 extern Sequence
< OUString
> SAL_CALL
88 SmXMLExportSettings_getSupportedServiceNames() throw();
89 extern OUString SAL_CALL
90 SmXMLExportSettings_getImplementationName() throw();
91 extern Reference
< XInterface
> SAL_CALL
92 SmXMLExportSettings_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
93 extern Sequence
< OUString
> SAL_CALL
94 SmXMLExportContent_getSupportedServiceNames() throw();
95 extern OUString SAL_CALL
96 SmXMLExportContent_getImplementationName() throw();
97 extern Reference
< XInterface
> SAL_CALL
98 SmXMLExportContent_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
103 SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
sm_component_getFactory( const sal_Char
* pImplementationName
,
104 void* pServiceManager
,
105 void* /*pRegistryKey*/ )
107 // Set default return value for this operation - if it failed.
108 void* pReturn
= NULL
;
111 ( pImplementationName
!= NULL
) &&
112 ( pServiceManager
!= NULL
)
115 // Define variables which are used in following macros.
116 Reference
< XSingleServiceFactory
> xFactory
;
117 Reference
< XMultiServiceFactory
> xServiceManager( reinterpret_cast< XMultiServiceFactory
* >( pServiceManager
) ) ;
119 if( SmXMLImport_getImplementationName().equalsAscii( pImplementationName
))
121 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
122 SmXMLImport_getImplementationName(),
123 SmXMLImport_createInstance
,
124 SmXMLImport_getSupportedServiceNames() );
126 else if( SmXMLExport_getImplementationName().equalsAscii( pImplementationName
))
128 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
129 SmXMLExport_getImplementationName(),
130 SmXMLExport_createInstance
,
131 SmXMLExport_getSupportedServiceNames() );
133 else if( SmXMLImportMeta_getImplementationName().equalsAscii( pImplementationName
))
135 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
136 SmXMLImportMeta_getImplementationName(),
137 SmXMLImportMeta_createInstance
,
138 SmXMLImportMeta_getSupportedServiceNames() );
140 else if( SmXMLExportMetaOOO_getImplementationName().equalsAscii( pImplementationName
))
142 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
143 SmXMLExportMetaOOO_getImplementationName(),
144 SmXMLExportMetaOOO_createInstance
,
145 SmXMLExportMetaOOO_getSupportedServiceNames() );
147 else if( SmXMLExportMeta_getImplementationName().equalsAscii( pImplementationName
))
149 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
150 SmXMLExportMeta_getImplementationName(),
151 SmXMLExportMeta_createInstance
,
152 SmXMLExportMeta_getSupportedServiceNames() );
154 else if( SmXMLImportSettings_getImplementationName().equalsAscii( pImplementationName
))
156 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
157 SmXMLImportSettings_getImplementationName(),
158 SmXMLImportSettings_createInstance
,
159 SmXMLImportSettings_getSupportedServiceNames() );
161 else if( SmXMLExportSettingsOOO_getImplementationName().equalsAscii( pImplementationName
))
163 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
164 SmXMLExportSettingsOOO_getImplementationName(),
165 SmXMLExportSettingsOOO_createInstance
,
166 SmXMLExportSettingsOOO_getSupportedServiceNames() );
168 else if( SmXMLExportSettings_getImplementationName().equalsAscii( pImplementationName
))
170 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
171 SmXMLExportSettings_getImplementationName(),
172 SmXMLExportSettings_createInstance
,
173 SmXMLExportSettings_getSupportedServiceNames() );
175 else if( SmXMLExportContent_getImplementationName().equalsAscii( pImplementationName
))
177 xFactory
= ::cppu::createSingleFactory( xServiceManager
,
178 SmXMLExportContent_getImplementationName(),
179 SmXMLExportContent_createInstance
,
180 SmXMLExportContent_getSupportedServiceNames() );
182 else if( SmDocument_getImplementationName().equalsAscii( pImplementationName
))
184 xFactory
= ::sfx2::createSfxModelFactory( xServiceManager
,
185 SmDocument_getImplementationName(),
186 SmDocument_createInstance
,
187 SmDocument_getSupportedServiceNames() );
191 // Factory is valid - service was found.
195 pReturn
= xFactory
.get();
199 // Return with result of this operation.
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */