update dev300-m58
[ooovba.git] / dbaccess / source / sdbtools / misc / sdbt_services.cxx
blob0a1757d449908156786d5784fd6057d0a5aa920e
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: sdbt_services.cxx,v $
10 * $Revision: 1.5 $
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 #ifndef DBACCESS_MODULE_SDBT_HXX
35 #include "module_sdbt.hxx"
36 #endif
38 /** === begin UNO using === **/
39 using ::com::sun::star::lang::XMultiServiceFactory;
40 using ::com::sun::star::registry::XRegistryKey;
41 using ::com::sun::star::registry::InvalidRegistryException;
42 using ::com::sun::star::uno::Reference;
43 using ::com::sun::star::uno::XInterface;
44 /** === end UNO using === **/
46 extern "C" void SAL_CALL createRegistryInfo_ConnectionTools();
48 //---------------------------------------------------------------------------------------
50 extern "C" void SAL_CALL sdbt_initializeModule()
52 static sal_Bool s_bInit = sal_False;
53 if (!s_bInit)
55 createRegistryInfo_ConnectionTools();
56 s_bInit = sal_True;
60 //---------------------------------------------------------------------------------------
62 extern "C" void SAL_CALL component_getImplementationEnvironment(
63 const sal_Char **ppEnvTypeName,
64 uno_Environment **
67 sdbt_initializeModule();
68 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
71 //---------------------------------------------------------------------------------------
72 extern "C" sal_Bool SAL_CALL component_writeInfo(
73 void* pServiceManager,
74 void* pRegistryKey
77 if (pRegistryKey)
78 try
80 return ::sdbtools::SdbtModule::getInstance().writeComponentInfos(
81 static_cast<XMultiServiceFactory*>(pServiceManager),
82 static_cast<XRegistryKey*>(pRegistryKey));
84 catch (const InvalidRegistryException& )
86 OSL_ASSERT("sdbt::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
89 return sal_False;
92 //---------------------------------------------------------------------------------------
93 extern "C" void* SAL_CALL component_getFactory(
94 const sal_Char* pImplementationName,
95 void* pServiceManager,
96 void* /*pRegistryKey*/)
98 Reference< XInterface > xRet;
99 if (pServiceManager && pImplementationName)
101 xRet = ::sdbtools::SdbtModule::getInstance().getComponentFactory(
102 ::rtl::OUString::createFromAscii(pImplementationName),
103 static_cast< XMultiServiceFactory* >(pServiceManager));
106 if (xRet.is())
107 xRet->acquire();
108 return xRet.get();