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 <cppuhelper/factory.hxx>
21 : #include <cppuhelper/implementationentry.hxx>
22 : #include "module_dba.hxx"
23 : #include <osl/diagnose.h>
24 : #include "DatabaseDataProvider.hxx"
25 : #include "dbadllapi.hxx"
26 :
27 : #include <../dataaccess/databasecontext.hxx>
28 :
29 : using namespace ::com::sun::star::uno;
30 : using namespace ::com::sun::star::lang;
31 : using namespace ::com::sun::star::registry;
32 :
33 : // registry functions
34 : extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition();
35 : extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition();
36 : extern "C" void SAL_CALL createRegistryInfo_ORowSet();
37 : extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument();
38 : extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource();
39 : extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory();
40 :
41 : namespace dba{
42 : ::cppu::ImplementationEntry entries[] = {
43 : {
44 : &::dbaccess::DatabaseDataProvider::Create,
45 : &::dbaccess::DatabaseDataProvider::getImplementationName_Static,
46 : &::dbaccess::DatabaseDataProvider::getSupportedServiceNames_Static,
47 : &cppu::createSingleComponentFactory, 0, 0
48 : },
49 :
50 : {
51 : &dbaccess::ODatabaseContext::Create,
52 : &dbaccess::ODatabaseContext::getImplementationName_static,
53 : &dbaccess::ODatabaseContext::getSupportedServiceNames_static,
54 : &cppu::createOneInstanceComponentFactory, 0, 0
55 : },
56 :
57 : { 0, 0, 0, 0, 0, 0 }
58 : };
59 : }
60 :
61 : // The prescribed C api must be complied with
62 : // It consists of three functions which must be exported by the module.
63 0 : extern "C" void SAL_CALL createRegistryInfo_DBA()
64 : {
65 : static sal_Bool bInit = sal_False;
66 0 : if (!bInit)
67 : {
68 0 : createRegistryInfo_OCommandDefinition();
69 0 : createRegistryInfo_OComponentDefinition();
70 0 : createRegistryInfo_ORowSet();
71 0 : createRegistryInfo_ODatabaseDocument();
72 0 : createRegistryInfo_ODatabaseSource();
73 0 : createRegistryInfo_DataAccessDescriptorFactory();
74 0 : bInit = sal_True;
75 : }
76 0 : }
77 :
78 0 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL dba_component_getFactory(
79 : const sal_Char* pImplementationName,
80 : void* pServiceManager,
81 : void* pRegistryKey)
82 : {
83 0 : createRegistryInfo_DBA();
84 :
85 0 : Reference< XInterface > xRet;
86 0 : if (pServiceManager && pImplementationName)
87 : {
88 0 : xRet = ::dba::DbaModule::getInstance().getComponentFactory(
89 0 : OUString::createFromAscii( pImplementationName ) );
90 : }
91 :
92 0 : if (xRet.is())
93 0 : xRet->acquire();
94 : else
95 : return cppu::component_getFactoryHelper(
96 0 : pImplementationName, pServiceManager, pRegistryKey, dba::entries);
97 0 : return xRet.get();
98 : };
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|