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: XMLFilterRegistration.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_xmloff.hxx"
35 #include <com/sun/star/registry/XRegistryKey.hpp>
36 #include <cppuhelper/factory.hxx>
38 using namespace ::com::sun::star
;
40 #define DECLARE_SERVICE( classname ) \
41 extern ::rtl::OUString SAL_CALL classname##_getImplementationName() throw(); \
42 extern uno::Sequence< ::rtl::OUString > SAL_CALL classname##_getSupportedServiceNames() throw(); \
43 extern uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance( \
44 const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
46 #define ENUMERATE_SERVICE( classname ) \
47 { classname##_getImplementationName, classname##_getSupportedServiceNames, classname##_createInstance }
49 // ============================================================================
50 DECLARE_SERVICE( OOo2OasisTransformer
)
51 DECLARE_SERVICE( Oasis2OOoTransformer
)
53 DECLARE_SERVICE( XMLAutoTextEventImportOOO
)
54 DECLARE_SERVICE( XMLMetaImportOOO
)
55 DECLARE_SERVICE( XMLMathSettingsImportOOO
)
56 DECLARE_SERVICE( XMLMathMetaImportOOO
)
57 DECLARE_SERVICE( XMLCalcSettingsImportOOO
)
58 DECLARE_SERVICE( XMLCalcMetaImportOOO
)
59 DECLARE_SERVICE( XMLCalcContentImportOOO
)
60 DECLARE_SERVICE( XMLCalcStylesImportOOO
)
61 DECLARE_SERVICE( XMLCalcImportOOO
)
62 DECLARE_SERVICE( XMLWriterSettingsImportOOO
)
63 DECLARE_SERVICE( XMLWriterMetaImportOOO
)
64 DECLARE_SERVICE( XMLWriterContentImportOOO
)
65 DECLARE_SERVICE( XMLWriterStylesImportOOO
)
66 DECLARE_SERVICE( XMLWriterImportOOO
)
67 DECLARE_SERVICE( XMLChartContentImportOOO
)
68 DECLARE_SERVICE( XMLChartStylesImportOOO
)
69 DECLARE_SERVICE( XMLChartImportOOO
)
70 DECLARE_SERVICE( XMLDrawSettingsImportOOO
)
71 DECLARE_SERVICE( XMLDrawMetaImportOOO
)
72 DECLARE_SERVICE( XMLDrawContentImportOOO
)
73 DECLARE_SERVICE( XMLDrawStylesImportOOO
)
74 DECLARE_SERVICE( XMLDrawImportOOO
)
75 DECLARE_SERVICE( XMLImpressSettingsImportOOO
)
76 DECLARE_SERVICE( XMLImpressMetaImportOOO
)
77 DECLARE_SERVICE( XMLImpressContentImportOOO
)
78 DECLARE_SERVICE( XMLImpressStylesImportOOO
)
79 DECLARE_SERVICE( XMLImpressImportOOO
)
81 // ============================================================================
83 // ----------------------------------------------------------------------------
86 typedef ::rtl::OUString (SAL_CALL
* GetImplementationName
)();
87 typedef uno::Sequence
< ::rtl::OUString
> (SAL_CALL
* GetSupportedServiceNames
)();
88 typedef uno::Reference
< ::uno::XInterface
> (SAL_CALL
* CreateInstance
)(
89 const uno::Reference
< lang::XMultiServiceFactory
>& );
91 struct ServiceDescriptor
93 GetImplementationName getImplementationName
;
94 GetSupportedServiceNames getSupportedServiceNames
;
95 CreateInstance createInstance
;
98 // ------------------------------------------------------------------------
99 static const ServiceDescriptor
* getServiceDescriptors()
101 static const ServiceDescriptor aDescriptors
[] =
103 // ================================================================
104 ENUMERATE_SERVICE( OOo2OasisTransformer
),
105 ENUMERATE_SERVICE( Oasis2OOoTransformer
),
107 ENUMERATE_SERVICE( XMLAutoTextEventImportOOO
),
108 ENUMERATE_SERVICE( XMLMetaImportOOO
),
109 ENUMERATE_SERVICE( XMLMathSettingsImportOOO
),
110 ENUMERATE_SERVICE( XMLMathMetaImportOOO
),
111 ENUMERATE_SERVICE( XMLCalcSettingsImportOOO
),
112 ENUMERATE_SERVICE( XMLCalcMetaImportOOO
),
113 ENUMERATE_SERVICE( XMLCalcContentImportOOO
),
114 ENUMERATE_SERVICE( XMLCalcStylesImportOOO
),
115 ENUMERATE_SERVICE( XMLCalcImportOOO
),
116 ENUMERATE_SERVICE( XMLWriterSettingsImportOOO
),
117 ENUMERATE_SERVICE( XMLWriterMetaImportOOO
),
118 ENUMERATE_SERVICE( XMLWriterContentImportOOO
),
119 ENUMERATE_SERVICE( XMLWriterStylesImportOOO
),
120 ENUMERATE_SERVICE( XMLWriterImportOOO
),
121 ENUMERATE_SERVICE( XMLChartContentImportOOO
),
122 ENUMERATE_SERVICE( XMLChartStylesImportOOO
),
123 ENUMERATE_SERVICE( XMLChartImportOOO
),
124 ENUMERATE_SERVICE( XMLDrawSettingsImportOOO
),
125 ENUMERATE_SERVICE( XMLDrawMetaImportOOO
),
126 ENUMERATE_SERVICE( XMLDrawContentImportOOO
),
127 ENUMERATE_SERVICE( XMLDrawStylesImportOOO
),
128 ENUMERATE_SERVICE( XMLDrawImportOOO
),
129 ENUMERATE_SERVICE( XMLImpressSettingsImportOOO
),
130 ENUMERATE_SERVICE( XMLImpressMetaImportOOO
),
131 ENUMERATE_SERVICE( XMLImpressContentImportOOO
),
132 ENUMERATE_SERVICE( XMLImpressStylesImportOOO
),
133 ENUMERATE_SERVICE( XMLImpressImportOOO
),
134 // ================================================================
140 // ----------------------------------------------------------------------------
147 void SAL_CALL
component_getImplementationEnvironment( const sal_Char
** ppEnvTypeName
, uno_Environment
** )
149 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
152 sal_Bool SAL_CALL
component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey
)
158 uno::Reference
< registry::XRegistryKey
> xMasterKey( reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
) );
160 const ServiceDescriptor
* pDescriptor
= getServiceDescriptors();
161 while ( pDescriptor
->getImplementationName
)
163 ::rtl::OUString
sNewKeyName( RTL_CONSTASCII_USTRINGPARAM("/") );
164 sNewKeyName
+= pDescriptor
->getImplementationName();
165 sNewKeyName
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
167 uno::Reference
< registry::XRegistryKey
> xNewKey( xMasterKey
->createKey( sNewKeyName
) );
169 uno::Sequence
< ::rtl::OUString
> aServices
= pDescriptor
->getSupportedServiceNames();
170 const ::rtl::OUString
* pServices
= aServices
.getConstArray();
171 for( sal_Int32 i
= 0; i
< aServices
.getLength(); ++i
, ++pServices
)
172 xNewKey
->createKey( *pServices
);
177 catch (registry::InvalidRegistryException
&)
179 OSL_ENSURE( sal_False
, "xof::component_writeInfo: InvalidRegistryException!" );
185 void * SAL_CALL
component_getFactory( const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
188 if( pServiceManager
)
192 uno::Reference
< lang::XMultiServiceFactory
> xMSF( reinterpret_cast< lang::XMultiServiceFactory
* >( pServiceManager
) );
194 const sal_Int32 nImplNameLen
= strlen( pImplName
);
196 const ServiceDescriptor
* pDescriptor
= getServiceDescriptors();
197 while ( pDescriptor
->getImplementationName
)
199 if ( pDescriptor
->getImplementationName().equalsAsciiL( pImplName
, nImplNameLen
) )
201 uno::Reference
< lang::XSingleServiceFactory
> xFactory
=
202 ::cppu::createSingleFactory( xMSF
,
203 pDescriptor
->getImplementationName(),
204 pDescriptor
->createInstance
,
205 pDescriptor
->getSupportedServiceNames()
211 pRet
= xFactory
.get();
219 catch( uno::Exception
& )
221 OSL_ENSURE( sal_False
, "xof::component_getFactory: Exception!" );