update dev300-m57
[ooovba.git] / cppuhelper / source / implementationentry.cxx
blob0ac0d7b3c7d082d867c8c592d8f7bd47d7c33a4b
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: implementationentry.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_cppuhelper.hxx"
33 #include <cppuhelper/implementationentry.hxx>
34 #include <rtl/ustrbuf.hxx>
36 using namespace ::rtl;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::registry;
41 namespace cppu {
43 sal_Bool component_writeInfoHelper(
44 void *, void *pRegistryKey , const struct ImplementationEntry entries[] )
46 sal_Bool bRet = sal_False;
47 try
49 if( pRegistryKey )
51 for( sal_Int32 i = 0; entries[i].create ; i ++ )
53 OUStringBuffer buf( 124 );
54 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/") );
55 buf.append( entries[i].getImplementationName() );
56 buf.appendAscii(RTL_CONSTASCII_STRINGPARAM( "/UNO/SERVICES" ) );
57 Reference< XRegistryKey > xNewKey(
58 reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( buf.makeStringAndClear() ) );
60 Sequence< OUString > seq = entries[i].getSupportedServiceNames();
61 const OUString *pArray = seq.getConstArray();
62 for ( sal_Int32 nPos = 0 ; nPos < seq.getLength(); nPos ++ )
63 xNewKey->createKey( pArray[nPos] );
65 bRet = sal_True;
68 catch ( InvalidRegistryException & )
70 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
72 return bRet;
76 void * component_getFactoryHelper(
77 const sal_Char * pImplName, void *, void *,
78 const struct ImplementationEntry entries[] )
81 void * pRet = 0;
82 Reference< XSingleComponentFactory > xFactory;
84 for( sal_Int32 i = 0 ; entries[i].create ; i ++ )
86 OUString implName = entries[i].getImplementationName();
87 if( 0 == implName.compareToAscii( pImplName ) )
89 xFactory = entries[i].createFactory(
90 entries[i].create,
91 implName,
92 entries[i].getSupportedServiceNames(),
93 entries[i].moduleCounter );
97 if( xFactory.is() )
99 xFactory->acquire();
100 pRet = xFactory.get();
102 return pRet;