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