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 : #include <cppuhelper/factory.hxx>
32 :
33 : #include "../dom/documentbuilder.hxx"
34 : #include "../dom/saxbuilder.hxx"
35 : #include "../xpath/xpathapi.hxx"
36 : #include "../events/testlistener.hxx"
37 :
38 : using namespace ::DOM;
39 : using namespace ::DOM::events;
40 : using namespace ::XPath;
41 : using ::rtl::OUString;
42 : using namespace ::com::sun::star::uno;
43 : using namespace ::com::sun::star::lang;
44 : using namespace ::com::sun::star::registry;
45 :
46 : extern "C"
47 : {
48 :
49 43 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL unoxml_component_getFactory(const sal_Char *pImplementationName, void *pServiceManager, void * /*pRegistryKey*/)
50 : {
51 43 : void* pReturn = NULL ;
52 43 : if ( pImplementationName && pServiceManager )
53 : {
54 : // Define variables which are used in following macros.
55 43 : Reference< XSingleServiceFactory > xFactory;
56 : Reference< XMultiServiceFactory > xServiceManager(
57 43 : reinterpret_cast< XMultiServiceFactory* >(pServiceManager));
58 :
59 43 : if (CDocumentBuilder::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
60 : {
61 : xFactory = Reference< XSingleServiceFactory >(
62 : cppu::createOneInstanceFactory(
63 : xServiceManager, CDocumentBuilder::_getImplementationName(),
64 16 : CDocumentBuilder::_getInstance, CDocumentBuilder::_getSupportedServiceNames()));
65 : }
66 27 : else if (CSAXDocumentBuilder::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
67 : {
68 : xFactory = Reference< XSingleServiceFactory >(
69 : cppu::createSingleFactory(
70 : xServiceManager, CSAXDocumentBuilder::_getImplementationName(),
71 11 : CSAXDocumentBuilder::_getInstance, CSAXDocumentBuilder::_getSupportedServiceNames()));
72 : }
73 16 : else if (CXPathAPI::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
74 : {
75 : xFactory = Reference< XSingleServiceFactory >(
76 : cppu::createSingleFactory(
77 : xServiceManager, CXPathAPI::_getImplementationName(),
78 16 : CXPathAPI::_getInstance, CXPathAPI::_getSupportedServiceNames()));
79 : }
80 0 : else if (CTestListener::_getImplementationName().compareToAscii( pImplementationName ) == 0 )
81 : {
82 : xFactory = Reference< XSingleServiceFactory >(
83 : cppu::createSingleFactory(
84 : xServiceManager, CTestListener::_getImplementationName(),
85 0 : CTestListener::_getInstance, CTestListener::_getSupportedServiceNames()));
86 : }
87 :
88 : // Factory is valid - service was found.
89 43 : if ( xFactory.is() )
90 : {
91 43 : xFactory->acquire();
92 43 : pReturn = xFactory.get();
93 43 : }
94 : }
95 :
96 : // Return with result of this operation.
97 43 : return pReturn ;
98 : }
99 :
100 : } // extern "C"
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|