bump product version to 5.0.4.1
[LibreOffice.git] / mysqlc / source / mysqlc_services.cxx
blob1671b87772c301d004568a51c611d3524ca08ee9
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 "mysqlc_driver.hxx"
22 #include <cppuhelper/factory.hxx>
23 #include <osl/diagnose.h>
24 #include <rtl/ustrbuf.hxx>
25 #include <uno/lbnames.h>
27 using namespace connectivity::mysqlc;
28 using ::com::sun::star::uno::Reference;
29 using ::com::sun::star::uno::Sequence;
30 using ::com::sun::star::registry::XRegistryKey;
31 using ::com::sun::star::lang::XSingleServiceFactory;
32 using ::com::sun::star::lang::XMultiServiceFactory;
34 typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
36 const Reference< XMultiServiceFactory > & rServiceManager,
37 const rtl::OUString & rComponentName,
38 ::cppu::ComponentInstantiation pCreateFunction,
39 const Sequence< rtl::OUString > & rServiceNames,
40 rtl_ModuleCount*
43 struct ProviderRequest
45 Reference< XSingleServiceFactory > xRet;
46 Reference< XMultiServiceFactory > const xServiceManager;
47 rtl::OUString const sImplementationName;
49 ProviderRequest(
50 void* pServiceManager,
51 sal_Char const* pImplementationName
52 ) : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
53 , sImplementationName(rtl::OUString::createFromAscii(pImplementationName))
57 inline bool CREATE_PROVIDER(
58 const rtl::OUString& Implname,
59 const Sequence< rtl::OUString > & Services,
60 ::cppu::ComponentInstantiation Factory,
61 createFactoryFunc creator
64 if (!xRet.is() && (Implname == sImplementationName)) {
65 try {
66 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
67 } catch (...) {
70 return xRet.is();
73 void* getProvider() const { return xRet.get(); }
76 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
77 const sal_Char * pImplementationName,
78 void * pServiceManager,
79 void * /* pRegistryKey */)
81 void* pRet = 0;
82 if (pServiceManager) {
83 ProviderRequest aReq(pServiceManager,pImplementationName);
85 aReq.CREATE_PROVIDER(
86 MysqlCDriver::getImplementationName_Static(),
87 MysqlCDriver::getSupportedServiceNames_Static(),
88 MysqlCDriver_CreateInstance, ::cppu::createSingleFactory)
91 if(aReq.xRet.is()) {
92 aReq.xRet->acquire();
95 pRet = aReq.getProvider();
98 return pRet;
101 extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
102 component_getImplementationEnvironment(
103 char const ** ppEnvTypeName, uno_Environment **)
105 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
109 * Local variables:
110 * tab-width: 4
111 * c-basic-offset: 4
112 * End:
113 * vim600: noet sw=4 ts=4 fdm=marker
114 * vim<600: noet sw=4 ts=4
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */