update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / kab / KServices.cxx
blobc4d9618ea29a2716e0e90ce2eb71dbb6256d2146
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 .
21 #include <config_vclplug.h>
22 #include "KDriver.hxx"
23 #include <cppuhelper/factory.hxx>
25 #if ENABLE_TDE
27 #define kab_component_getFactory tdeab_component_getFactory
29 #endif // ENABLE_TDE
31 using namespace connectivity::kab;
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::Sequence;
34 using ::com::sun::star::lang::XSingleServiceFactory;
35 using ::com::sun::star::lang::XMultiServiceFactory;
37 typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
39 const Reference< XMultiServiceFactory > & rServiceManager,
40 const OUString & rComponentName,
41 ::cppu::ComponentInstantiation pCreateFunction,
42 const Sequence< OUString > & rServiceNames,
43 rtl_ModuleCount*
47 struct ProviderRequest
49 Reference< XSingleServiceFactory > xRet;
50 Reference< XMultiServiceFactory > const xServiceManager;
51 OUString const sImplementationName;
53 ProviderRequest(
54 void* pServiceManager,
55 sal_Char const* pImplementationName
57 : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
58 , sImplementationName(OUString::createFromAscii(pImplementationName))
62 inline
63 bool CREATE_PROVIDER(
64 const OUString& Implname,
65 const Sequence< OUString > & Services,
66 ::cppu::ComponentInstantiation Factory,
67 createFactoryFunc creator
70 if (!xRet.is() && (Implname == sImplementationName))
72 try
74 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
76 catch(...)
80 return xRet.is();
83 void* getProvider() const { return xRet.get(); }
87 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL kab_component_getFactory(
88 const sal_Char* pImplementationName,
89 void* pServiceManager,
90 void*)
92 void* pRet = 0;
93 if (pServiceManager)
95 ProviderRequest aReq(pServiceManager,pImplementationName);
97 aReq.CREATE_PROVIDER(
98 KabDriver::getImplementationName_Static(),
99 KabDriver::getSupportedServiceNames_Static(),
100 &KabDriver::Create,
101 ::cppu::createSingleFactory)
104 if (aReq.xRet.is())
105 aReq.xRet->acquire();
107 pRet = aReq.getProvider();
110 return pRet;
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */