Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <osl/mutex.hxx>
21 : #include <rtl/ustring.hxx>
22 : #include <com/sun/star/uno/Reference.h>
23 : #include <com/sun/star/uno/Reference.hxx>
24 : #include <cppuhelper/interfacecontainer.h>
25 : #include <cppuhelper/factory.hxx>
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <com/sun/star/uno/Exception.hpp>
28 : #include <com/sun/star/lang/XComponent.hpp>
29 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30 : #include <com/sun/star/registry/XRegistryKey.hpp>
31 :
32 : #include "../dom/documentbuilder.hxx"
33 : #include "../dom/saxbuilder.hxx"
34 : #include "../xpath/xpathapi.hxx"
35 : #include "../events/testlistener.hxx"
36 :
37 : using namespace ::DOM;
38 : using namespace ::DOM::events;
39 : using namespace ::XPath;
40 : using namespace ::com::sun::star::uno;
41 : using namespace ::com::sun::star::lang;
42 : using namespace ::com::sun::star::registry;
43 :
44 : extern "C"
45 : {
46 :
47 0 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL unoxml_component_getFactory(const sal_Char *pImplementationName, void *pServiceManager, void * /*pRegistryKey*/)
48 : {
49 0 : void* pReturn = NULL ;
50 0 : if ( pImplementationName && pServiceManager )
51 : {
52 : // Define variables which are used in following macros.
53 0 : Reference< XSingleServiceFactory > xFactory;
54 : Reference< XMultiServiceFactory > xServiceManager(
55 0 : reinterpret_cast< XMultiServiceFactory* >(pServiceManager));
56 :
57 0 : if (CDocumentBuilder::_getImplementationName().equalsAscii( pImplementationName ) )
58 : {
59 0 : xFactory = Reference< XSingleServiceFactory >(
60 : cppu::createOneInstanceFactory(
61 : xServiceManager, CDocumentBuilder::_getImplementationName(),
62 0 : CDocumentBuilder::_getInstance, CDocumentBuilder::_getSupportedServiceNames()));
63 : }
64 0 : else if (CSAXDocumentBuilder::_getImplementationName().equalsAscii( pImplementationName ) )
65 : {
66 0 : xFactory = Reference< XSingleServiceFactory >(
67 : cppu::createSingleFactory(
68 : xServiceManager, CSAXDocumentBuilder::_getImplementationName(),
69 0 : CSAXDocumentBuilder::_getInstance, CSAXDocumentBuilder::_getSupportedServiceNames()));
70 : }
71 0 : else if (CXPathAPI::_getImplementationName().equalsAscii( pImplementationName ) )
72 : {
73 0 : xFactory = Reference< XSingleServiceFactory >(
74 : cppu::createSingleFactory(
75 : xServiceManager, CXPathAPI::_getImplementationName(),
76 0 : CXPathAPI::_getInstance, CXPathAPI::_getSupportedServiceNames()));
77 : }
78 0 : else if (CTestListener::_getImplementationName().equalsAscii( pImplementationName ) )
79 : {
80 0 : xFactory = Reference< XSingleServiceFactory >(
81 : cppu::createSingleFactory(
82 : xServiceManager, CTestListener::_getImplementationName(),
83 0 : CTestListener::_getInstance, CTestListener::_getSupportedServiceNames()));
84 : }
85 :
86 : // Factory is valid - service was found.
87 0 : if ( xFactory.is() )
88 : {
89 0 : xFactory->acquire();
90 0 : pReturn = xFactory.get();
91 0 : }
92 : }
93 :
94 : // Return with result of this operation.
95 0 : return pReturn ;
96 : }
97 :
98 : } // extern "C"
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|