merge the formfield patch from ooo-build
[ooovba.git] / sax / source / fastparser / facreg.cxx
blob8022be967fc62893e57232b3cd95398def2b4a19
1 #include <cppuhelper/factory.hxx>
2 #include <cppuhelper/weak.hxx>
3 #include <cppuhelper/implbase2.hxx>
5 #include "../tools/fastserializer.hxx"
6 #include "fastparser.hxx"
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;
15 namespace sax_fastparser
18 //--------------------------------------
19 // the extern interface
20 //---------------------------------------
21 Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance( const Reference< XMultiServiceFactory > & ) throw(Exception)
23 FastSaxParser *p = new FastSaxParser;
24 return Reference< XInterface > ( (OWeakObject * ) p );
27 Reference< XInterface > SAL_CALL FastSaxSerializer_CreateInstance( const Reference< XMultiServiceFactory > & ) throw(Exception)
29 FastSaxSerializer *p = new FastSaxSerializer;
30 return Reference< XInterface > ( (OWeakObject * ) p );
34 extern "C"
37 void SAL_CALL component_getImplementationEnvironment(
38 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
40 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
44 sal_Bool SAL_CALL component_writeInfo(
45 void * /*pServiceManager*/, void * pRegistryKey )
47 if (pRegistryKey)
49 try
51 Reference< XRegistryKey > xKey( reinterpret_cast< XRegistryKey * >( pRegistryKey ) );
53 Reference< XRegistryKey > xNewKey( xKey->createKey(
54 OUString::createFromAscii( "/" PARSER_IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
55 xNewKey->createKey( OUString::createFromAscii( PARSER_SERVICE_NAME ) );
57 Reference< XRegistryKey > xNewKey1( xKey->createKey(
58 OUString::createFromAscii( "/" SERIALIZER_IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
59 xNewKey1->createKey( OUString::createFromAscii( SERIALIZER_SERVICE_NAME ) );
61 return sal_True;
63 catch (InvalidRegistryException &)
65 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
68 return sal_False;
71 void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
73 void * pRet = 0;
75 if (pServiceManager )
77 Reference< XSingleServiceFactory > xRet;
78 Reference< XMultiServiceFactory > xSMgr( reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ) );
80 OUString aImplementationName( OUString::createFromAscii( pImplName ) );
82 if (aImplementationName == OUString( RTL_CONSTASCII_USTRINGPARAM( PARSER_IMPLEMENTATION_NAME ) ) )
84 xRet = createSingleFactory( xSMgr, aImplementationName,
85 FastSaxParser_CreateInstance,
86 FastSaxParser::getSupportedServiceNames_Static() );
88 else if (aImplementationName == OUString( RTL_CONSTASCII_USTRINGPARAM( SERIALIZER_IMPLEMENTATION_NAME ) ) )
90 xRet = createSingleFactory( xSMgr, aImplementationName,
91 FastSaxSerializer_CreateInstance,
92 FastSaxSerializer::getSupportedServiceNames_Static() );
95 if (xRet.is())
97 xRet->acquire();
98 pRet = xRet.get();
102 return pRet;