xref: /aoo41x/main/sax/source/fastparser/facreg.cxx (revision f9b72d11)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <cppuhelper/factory.hxx>
23 #include <cppuhelper/weak.hxx>
24 #include <cppuhelper/implbase2.hxx>
25 
26 #include "../tools/fastserializer.hxx"
27 #include "fastparser.hxx"
28 
29 using namespace sax_fastparser;
30 using namespace ::cppu;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::registry;
33 using ::rtl::OUString;
34 using namespace ::com::sun::star::lang;
35 
36 namespace sax_fastparser
37 {
38 
39 //--------------------------------------
40 // the extern interface
41 //---------------------------------------
FastSaxParser_CreateInstance(const Reference<XMultiServiceFactory> &)42 Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance( const Reference< XMultiServiceFactory  >  & ) throw(Exception)
43 {
44 	FastSaxParser *p = new FastSaxParser;
45 	return Reference< XInterface > ( (OWeakObject * ) p );
46 }
47 
FastSaxSerializer_CreateInstance(const Reference<XMultiServiceFactory> &)48 Reference< XInterface > SAL_CALL FastSaxSerializer_CreateInstance( const Reference< XMultiServiceFactory  >  & ) throw(Exception)
49 {
50 	FastSaxSerializer *p = new FastSaxSerializer;
51 	return Reference< XInterface > ( (OWeakObject * ) p );
52 }
53 }
54 
55 extern "C"
56 {
57 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)58 void SAL_CALL component_getImplementationEnvironment(
59 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
60 {
61 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
62 }
63 
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)64 void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
65 {
66 	void * pRet = 0;
67 
68 	if (pServiceManager )
69 	{
70 		Reference< XSingleServiceFactory > xRet;
71 		Reference< XMultiServiceFactory > xSMgr( reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ) );
72 
73 		OUString aImplementationName( OUString::createFromAscii( pImplName ) );
74 
75 		if (aImplementationName == OUString( RTL_CONSTASCII_USTRINGPARAM( PARSER_IMPLEMENTATION_NAME  ) ) )
76 		{
77 			xRet = createSingleFactory( xSMgr, aImplementationName,
78 										FastSaxParser_CreateInstance,
79 										FastSaxParser::getSupportedServiceNames_Static() );
80 		}
81 		else if (aImplementationName == OUString( RTL_CONSTASCII_USTRINGPARAM( SERIALIZER_IMPLEMENTATION_NAME  ) ) )
82 		{
83 			xRet = createSingleFactory( xSMgr, aImplementationName,
84 										FastSaxSerializer_CreateInstance,
85 										FastSaxSerializer::getSupportedServiceNames_Static() );
86 		}
87 
88 		if (xRet.is())
89 		{
90 			xRet->acquire();
91 			pRet = xRet.get();
92 		}
93 	}
94 
95 	return pRet;
96 }
97 
98 
99 }
100