update dev300-m58
[ooovba.git] / dbaccess / source / core / misc / services.cxx
blobc334511ed9ae50101286ed9bca19e6e4d82ec443
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: services.cxx,v $
10 * $Revision: 1.18.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include <cppuhelper/factory.hxx>
35 #include <cppuhelper/implementationentry.hxx>
36 #include "module_dba.hxx"
37 #include <osl/diagnose.h>
38 #include "DatabaseDataProvider.hxx"
39 #include "dbadllapi.hxx"
41 /********************************************************************************************/
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::registry;
47 //***************************************************************************************
49 // registry functions
50 extern "C" void SAL_CALL createRegistryInfo_ODatabaseContext();
51 extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition();
52 extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition();
53 extern "C" void SAL_CALL createRegistryInfo_ORowSet();
54 extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument();
55 extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource();
56 extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory();
58 namespace dba{
59 //--------------------------------------------------------------------------
60 ::cppu::ImplementationEntry entries[] = {
61 { &::dbaccess::DatabaseDataProvider::Create, &::dbaccess::DatabaseDataProvider::getImplementationName_Static, &::dbaccess::DatabaseDataProvider::getSupportedServiceNames_Static,
62 &cppu::createSingleComponentFactory, 0, 0 },
63 { 0, 0, 0, 0, 0, 0 }
67 //***************************************************************************************
69 // Die vorgeschriebene C-Api muss erfuellt werden!
70 // Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
72 extern "C" void SAL_CALL createRegistryInfo_DBA()
74 static sal_Bool bInit = sal_False;
75 if (!bInit)
77 createRegistryInfo_ODatabaseContext();
78 createRegistryInfo_OCommandDefinition();
79 createRegistryInfo_OComponentDefinition();
80 createRegistryInfo_ORowSet();
81 createRegistryInfo_ODatabaseDocument();
82 createRegistryInfo_ODatabaseSource();
83 createRegistryInfo_DataAccessDescriptorFactory();
84 bInit = sal_True;
88 //---------------------------------------------------------------------------------------
90 extern "C" OOO_DLLPUBLIC_DBA void SAL_CALL component_getImplementationEnvironment(
91 const sal_Char **ppEnvTypeName,
92 uno_Environment **
95 createRegistryInfo_DBA();
96 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
99 //---------------------------------------------------------------------------------------
100 extern "C" OOO_DLLPUBLIC_DBA sal_Bool SAL_CALL component_writeInfo(
101 void* pServiceManager,
102 void* pRegistryKey
105 if (pRegistryKey)
108 return ::dba::DbaModule::getInstance().writeComponentInfos(
109 static_cast< XMultiServiceFactory* >( pServiceManager ),
110 static_cast< XRegistryKey* >( pRegistryKey ) )
111 && cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, dba::entries);
113 catch (InvalidRegistryException& )
115 OSL_ENSURE( false, "DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !" );
118 return sal_False;
121 //---------------------------------------------------------------------------------------
122 extern "C" OOO_DLLPUBLIC_DBA void* SAL_CALL component_getFactory(
123 const sal_Char* pImplementationName,
124 void* pServiceManager,
125 void* pRegistryKey)
127 Reference< XInterface > xRet;
128 if (pServiceManager && pImplementationName)
130 xRet = ::dba::DbaModule::getInstance().getComponentFactory(
131 ::rtl::OUString::createFromAscii( pImplementationName ),
132 static_cast< XMultiServiceFactory* >( pServiceManager ) );
135 if (xRet.is())
136 xRet->acquire();
137 else
138 return cppu::component_getFactoryHelper(
139 pImplementationName, pServiceManager, pRegistryKey, dba::entries);
140 return xRet.get();