1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 
31 #include <cppuhelper/factory.hxx>
32 #include <cppuhelper/implementationentry.hxx>
33 #include "module_dba.hxx"
34 #include <osl/diagnose.h>
35 #include "DatabaseDataProvider.hxx"
36 #include "dbadllapi.hxx"
37 
38 /********************************************************************************************/
39 
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star::registry;
43 
44 //***************************************************************************************
45 //
46 // registry functions
47 extern "C" void SAL_CALL createRegistryInfo_ODatabaseContext();
48 extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition();
49 extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition();
50 extern "C" void SAL_CALL createRegistryInfo_ORowSet();
51 extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument();
52 extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource();
53 extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory();
54 
55 namespace dba{
56 //--------------------------------------------------------------------------
57     ::cppu::ImplementationEntry entries[] = {
58         { &::dbaccess::DatabaseDataProvider::Create, &::dbaccess::DatabaseDataProvider::getImplementationName_Static, &::dbaccess::DatabaseDataProvider::getSupportedServiceNames_Static,
59 		    &cppu::createSingleComponentFactory, 0, 0 },
60 	    { 0, 0, 0, 0, 0, 0 }
61     };
62 }
63 
64 //***************************************************************************************
65 //
66 // Die vorgeschriebene C-Api muss erfuellt werden!
67 // Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
68 //
69 extern "C" void SAL_CALL createRegistryInfo_DBA()
70 {
71 	static sal_Bool bInit = sal_False;
72 	if (!bInit)
73 	{
74 		createRegistryInfo_ODatabaseContext();
75 		createRegistryInfo_OCommandDefinition();
76 		createRegistryInfo_OComponentDefinition();
77 		createRegistryInfo_ORowSet();
78 		createRegistryInfo_ODatabaseDocument();
79         createRegistryInfo_ODatabaseSource();
80         createRegistryInfo_DataAccessDescriptorFactory();
81 		bInit = sal_True;
82 	}
83 }
84 
85 //---------------------------------------------------------------------------------------
86 
87 extern "C" OOO_DLLPUBLIC_DBA void SAL_CALL component_getImplementationEnvironment(
88 				const sal_Char	**ppEnvTypeName,
89 				uno_Environment	**
90 			)
91 {
92 	createRegistryInfo_DBA();
93 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
94 }
95 
96 //---------------------------------------------------------------------------------------
97 extern "C" OOO_DLLPUBLIC_DBA void* SAL_CALL component_getFactory(
98 					const sal_Char* pImplementationName,
99 					void* pServiceManager,
100 					void* pRegistryKey)
101 {
102 	Reference< XInterface > xRet;
103 	if (pServiceManager && pImplementationName)
104 	{
105 		xRet = ::dba::DbaModule::getInstance().getComponentFactory(
106 			::rtl::OUString::createFromAscii( pImplementationName ),
107 			static_cast< XMultiServiceFactory* >( pServiceManager ) );
108 	}
109 
110 	if (xRet.is())
111 		xRet->acquire();
112     else
113         return cppu::component_getFactoryHelper(
114             pImplementationName, pServiceManager, pRegistryKey, dba::entries);
115 	return xRet.get();
116 };
117