1*e9cbe144SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*e9cbe144SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*e9cbe144SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*e9cbe144SAndrew Rist * distributed with this work for additional information
6*e9cbe144SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*e9cbe144SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*e9cbe144SAndrew Rist * "License"); you may not use this file except in compliance
9*e9cbe144SAndrew Rist * with the License. You may obtain a copy of the License at
10*e9cbe144SAndrew Rist *
11*e9cbe144SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*e9cbe144SAndrew Rist *
13*e9cbe144SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*e9cbe144SAndrew Rist * software distributed under the License is distributed on an
15*e9cbe144SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e9cbe144SAndrew Rist * KIND, either express or implied. See the License for the
17*e9cbe144SAndrew Rist * specific language governing permissions and limitations
18*e9cbe144SAndrew Rist * under the License.
19*e9cbe144SAndrew Rist *
20*e9cbe144SAndrew Rist *************************************************************/
21*e9cbe144SAndrew Rist
22*e9cbe144SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include <osl/mutex.hxx>
25cdf0e10cSrcweir #include <rtl/ustring.hxx>
26cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
27cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
28cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
29cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
31cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
35cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include "../dom/documentbuilder.hxx"
38cdf0e10cSrcweir #include "../dom/saxbuilder.hxx"
39cdf0e10cSrcweir #include "../xpath/xpathapi.hxx"
40cdf0e10cSrcweir #include "../events/testlistener.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace ::DOM;
43cdf0e10cSrcweir using namespace ::DOM::events;
44cdf0e10cSrcweir using namespace ::XPath;
45cdf0e10cSrcweir using ::rtl::OUString;
46cdf0e10cSrcweir using namespace ::com::sun::star::uno;
47cdf0e10cSrcweir using namespace ::com::sun::star::lang;
48cdf0e10cSrcweir using namespace ::com::sun::star::registry;
49cdf0e10cSrcweir
50cdf0e10cSrcweir extern "C"
51cdf0e10cSrcweir {
52cdf0e10cSrcweir
53cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT void SAL_CALL
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment **)54cdf0e10cSrcweir component_getImplementationEnvironment(const sal_Char **ppEnvironmentTypeName, uno_Environment ** /*ppEnvironment */)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
59cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT void* SAL_CALL
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)60cdf0e10cSrcweir component_getFactory(const sal_Char *pImplementationName, void *pServiceManager, void * /*pRegistryKey*/)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir void* pReturn = NULL ;
63cdf0e10cSrcweir if ( pImplementationName && pServiceManager )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir // Define variables which are used in following macros.
66cdf0e10cSrcweir Reference< XSingleServiceFactory > xFactory;
67cdf0e10cSrcweir Reference< XMultiServiceFactory > xServiceManager(
68cdf0e10cSrcweir reinterpret_cast< XMultiServiceFactory* >(pServiceManager));
69cdf0e10cSrcweir
70cdf0e10cSrcweir if (CDocumentBuilder::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir xFactory = Reference< XSingleServiceFactory >(
73cdf0e10cSrcweir cppu::createOneInstanceFactory(
74cdf0e10cSrcweir xServiceManager, CDocumentBuilder::_getImplementationName(),
75cdf0e10cSrcweir CDocumentBuilder::_getInstance, CDocumentBuilder::_getSupportedServiceNames()));
76cdf0e10cSrcweir }
77cdf0e10cSrcweir else if (CSAXDocumentBuilder::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir xFactory = Reference< XSingleServiceFactory >(
80cdf0e10cSrcweir cppu::createSingleFactory(
81cdf0e10cSrcweir xServiceManager, CSAXDocumentBuilder::_getImplementationName(),
82cdf0e10cSrcweir CSAXDocumentBuilder::_getInstance, CSAXDocumentBuilder::_getSupportedServiceNames()));
83cdf0e10cSrcweir }
84cdf0e10cSrcweir else if (CXPathAPI::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir xFactory = Reference< XSingleServiceFactory >(
87cdf0e10cSrcweir cppu::createSingleFactory(
88cdf0e10cSrcweir xServiceManager, CXPathAPI::_getImplementationName(),
89cdf0e10cSrcweir CXPathAPI::_getInstance, CXPathAPI::_getSupportedServiceNames()));
90cdf0e10cSrcweir }
91cdf0e10cSrcweir else if (CTestListener::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir xFactory = Reference< XSingleServiceFactory >(
94cdf0e10cSrcweir cppu::createSingleFactory(
95cdf0e10cSrcweir xServiceManager, CTestListener::_getImplementationName(),
96cdf0e10cSrcweir CTestListener::_getInstance, CTestListener::_getSupportedServiceNames()));
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir // Factory is valid - service was found.
100cdf0e10cSrcweir if ( xFactory.is() )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir xFactory->acquire();
103cdf0e10cSrcweir pReturn = xFactory.get();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir // Return with result of this operation.
108cdf0e10cSrcweir return pReturn ;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir } // extern "C"
112