update dev300-m58
[ooovba.git] / connectivity / source / cpool / Zregistration.cxx
blob4cf9705d971bea019c929a12071a640a5f6d39ca
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: Zregistration.cxx,v $
10 * $Revision: 1.6 $
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_connectivity.hxx"
34 #include <stdio.h>
35 #include <cppuhelper/factory.hxx>
36 #include "ZPoolCollection.hxx"
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::registry;
42 using namespace connectivity;
43 //==========================================================================
44 //= registration
45 //==========================================================================
46 extern "C"
49 //---------------------------------------------------------------------------------------
50 void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/)
52 *_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
55 //---------------------------------------------------------------------------------------
56 sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star::registry::XRegistryKey* _pRegistryKey)
58 ::rtl::OUString sMainKeyName = ::rtl::OUString::createFromAscii("/");
59 sMainKeyName += OPoolCollection::getImplementationName_Static();
60 sMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
62 try
64 Reference< XRegistryKey > xMainKey = _pRegistryKey->createKey(sMainKeyName);
65 if (!xMainKey.is())
66 return sal_False;
68 Sequence< ::rtl::OUString > sServices = OPoolCollection::getSupportedServiceNames_Static();
69 const ::rtl::OUString* pServices = sServices.getConstArray();
70 for (sal_Int32 i=0; i<sServices.getLength(); ++i, ++pServices)
71 xMainKey->createKey(*pServices);
73 catch(InvalidRegistryException&)
75 return sal_False;
77 catch(InvalidValueException&)
79 return sal_False;
81 return sal_True;
84 //---------------------------------------------------------------------------------------
85 void* SAL_CALL component_getFactory(const sal_Char* _pImplName, ::com::sun::star::lang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/)
87 void* pRet = NULL;
89 if (OPoolCollection::getImplementationName_Static().compareToAscii(_pImplName) == 0)
91 Reference< XSingleServiceFactory > xFactory(
92 ::cppu::createOneInstanceFactory(
93 _pServiceManager,
94 OPoolCollection::getImplementationName_Static(),
95 OPoolCollection::CreateInstance,
96 OPoolCollection::getSupportedServiceNames_Static()
99 if (xFactory.is())
101 xFactory->acquire();
102 pRet = xFactory.get();
106 return pRet;
109 } // extern "C"