Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / misc / services.cxx
blob5b42475750f18a673ce1f97db5708554cff30755
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 <cppuhelper/factory.hxx>
22 #include <cppuhelper/implementationentry.hxx>
23 #include "module_dba.hxx"
24 #include <osl/diagnose.h>
25 #include "DatabaseDataProvider.hxx"
26 #include "dbadllapi.hxx"
28 #include <../dataaccess/databasecontext.hxx>
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::registry;
35 //***************************************************************************************
37 // registry functions
38 extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition();
39 extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition();
40 extern "C" void SAL_CALL createRegistryInfo_ORowSet();
41 extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument();
42 extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource();
43 extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory();
45 namespace dba{
46 //--------------------------------------------------------------------------
47 ::cppu::ImplementationEntry entries[] = {
49 &::dbaccess::DatabaseDataProvider::Create,
50 &::dbaccess::DatabaseDataProvider::getImplementationName_Static,
51 &::dbaccess::DatabaseDataProvider::getSupportedServiceNames_Static,
52 &cppu::createSingleComponentFactory, 0, 0
56 &dbaccess::ODatabaseContext::Create,
57 &dbaccess::ODatabaseContext::getImplementationName_static,
58 &dbaccess::ODatabaseContext::getSupportedServiceNames_static,
59 &cppu::createOneInstanceComponentFactory, 0, 0
62 { 0, 0, 0, 0, 0, 0 }
66 //***************************************************************************************
68 // The prescribed C api must be complied with
69 // It consists of three functions which must be exported by the module.
71 extern "C" void SAL_CALL createRegistryInfo_DBA()
73 static sal_Bool bInit = sal_False;
74 if (!bInit)
76 createRegistryInfo_OCommandDefinition();
77 createRegistryInfo_OComponentDefinition();
78 createRegistryInfo_ORowSet();
79 createRegistryInfo_ODatabaseDocument();
80 createRegistryInfo_ODatabaseSource();
81 createRegistryInfo_DataAccessDescriptorFactory();
82 bInit = sal_True;
86 //---------------------------------------------------------------------------------------
87 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL dba_component_getFactory(
88 const sal_Char* pImplementationName,
89 void* pServiceManager,
90 void* pRegistryKey)
92 createRegistryInfo_DBA();
94 Reference< XInterface > xRet;
95 if (pServiceManager && pImplementationName)
97 xRet = ::dba::DbaModule::getInstance().getComponentFactory(
98 ::rtl::OUString::createFromAscii( pImplementationName ) );
101 if (xRet.is())
102 xRet->acquire();
103 else
104 return cppu::component_getFactoryHelper(
105 pImplementationName, pServiceManager, pRegistryKey, dba::entries);
106 return xRet.get();
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */