xref: /aoo41x/main/sax/source/fastparser/facreg.cxx (revision cdf0e10c)
1 #include <cppuhelper/factory.hxx>
2 #include <cppuhelper/weak.hxx>
3 #include <cppuhelper/implbase2.hxx>
4 
5 #include "../tools/fastserializer.hxx"
6 #include "fastparser.hxx"
7 
8 using namespace sax_fastparser;
9 using namespace ::cppu;
10 using namespace ::com::sun::star::uno;
11 using namespace ::com::sun::star::registry;
12 using ::rtl::OUString;
13 using namespace ::com::sun::star::lang;
14 
15 namespace sax_fastparser
16 {
17 
18 //--------------------------------------
19 // the extern interface
20 //---------------------------------------
21 Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance( const Reference< XMultiServiceFactory  >  & ) throw(Exception)
22 {
23 	FastSaxParser *p = new FastSaxParser;
24 	return Reference< XInterface > ( (OWeakObject * ) p );
25 }
26 
27 Reference< XInterface > SAL_CALL FastSaxSerializer_CreateInstance( const Reference< XMultiServiceFactory  >  & ) throw(Exception)
28 {
29 	FastSaxSerializer *p = new FastSaxSerializer;
30 	return Reference< XInterface > ( (OWeakObject * ) p );
31 }
32 }
33 
34 extern "C"
35 {
36 
37 void SAL_CALL component_getImplementationEnvironment(
38 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
39 {
40 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
41 }
42 
43 void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
44 {
45 	void * pRet = 0;
46 
47 	if (pServiceManager )
48 	{
49 		Reference< XSingleServiceFactory > xRet;
50 		Reference< XMultiServiceFactory > xSMgr( reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ) );
51 
52 		OUString aImplementationName( OUString::createFromAscii( pImplName ) );
53 
54 		if (aImplementationName == OUString( RTL_CONSTASCII_USTRINGPARAM( PARSER_IMPLEMENTATION_NAME  ) ) )
55 		{
56 			xRet = createSingleFactory( xSMgr, aImplementationName,
57 										FastSaxParser_CreateInstance,
58 										FastSaxParser::getSupportedServiceNames_Static() );
59 		}
60 		else if (aImplementationName == OUString( RTL_CONSTASCII_USTRINGPARAM( SERIALIZER_IMPLEMENTATION_NAME  ) ) )
61 		{
62 			xRet = createSingleFactory( xSMgr, aImplementationName,
63 										FastSaxSerializer_CreateInstance,
64 										FastSaxSerializer::getSupportedServiceNames_Static() );
65 		}
66 
67 		if (xRet.is())
68 		{
69 			xRet->acquire();
70 			pRet = xRet.get();
71 		}
72 	}
73 
74 	return pRet;
75 }
76 
77 
78 }
79