Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / unoxml / source / service / services.cxx
blobcf029fb3d01b195abcc671b4a061397813639ff2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <rtl/ustring.hxx>
21 #include <com/sun/star/uno/Reference.h>
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <cppuhelper/interfacecontainer.h>
24 #include <cppuhelper/factory.hxx>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/uno/Exception.hpp>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
29 #include <com/sun/star/registry/XRegistryKey.hpp>
31 #include "../dom/documentbuilder.hxx"
32 #include "../dom/saxbuilder.hxx"
33 #include "../xpath/xpathapi.hxx"
35 using namespace ::DOM;
36 using namespace ::XPath;
37 using namespace css::uno;
38 using namespace css::lang;
39 using namespace css::registry;
41 extern "C"
44 SAL_DLLPUBLIC_EXPORT void* unoxml_component_getFactory(const sal_Char *pImplementationName, void *pServiceManager, void * /*pRegistryKey*/)
46 void* pReturn = nullptr ;
47 if ( pImplementationName && pServiceManager )
49 // Define variables which are used in following macros.
50 Reference< XSingleServiceFactory > xFactory;
51 Reference< XMultiServiceFactory > xServiceManager(
52 static_cast< XMultiServiceFactory* >(pServiceManager));
54 if (CDocumentBuilder::_getImplementationName().equalsAscii( pImplementationName ) )
56 xFactory.set(
57 cppu::createOneInstanceFactory(
58 xServiceManager, CDocumentBuilder::_getImplementationName(),
59 CDocumentBuilder::_getInstance, CDocumentBuilder::_getSupportedServiceNames()));
61 else if (CSAXDocumentBuilder::_getImplementationName().equalsAscii( pImplementationName ) )
63 xFactory.set(
64 cppu::createSingleFactory(
65 xServiceManager, CSAXDocumentBuilder::_getImplementationName(),
66 CSAXDocumentBuilder::_getInstance, CSAXDocumentBuilder::_getSupportedServiceNames()));
68 else if (CXPathAPI::_getImplementationName().equalsAscii( pImplementationName ) )
70 xFactory.set(
71 cppu::createSingleFactory(
72 xServiceManager, CXPathAPI::_getImplementationName(),
73 CXPathAPI::_getInstance, CXPathAPI::_getSupportedServiceNames()));
76 // Factory is valid - service was found.
77 if ( xFactory.is() )
79 xFactory->acquire();
80 pReturn = xFactory.get();
84 // Return with result of this operation.
85 return pReturn ;
88 } // extern "C"
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */