1*9d7e27acSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9d7e27acSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9d7e27acSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9d7e27acSAndrew Rist  * distributed with this work for additional information
6*9d7e27acSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9d7e27acSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9d7e27acSAndrew Rist  * "License"); you may not use this file except in compliance
9*9d7e27acSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9d7e27acSAndrew Rist  *
11*9d7e27acSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9d7e27acSAndrew Rist  *
13*9d7e27acSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9d7e27acSAndrew Rist  * software distributed under the License is distributed on an
15*9d7e27acSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9d7e27acSAndrew Rist  * KIND, either express or implied.  See the License for the
17*9d7e27acSAndrew Rist  * specific language governing permissions and limitations
18*9d7e27acSAndrew Rist  * under the License.
19*9d7e27acSAndrew Rist  *
20*9d7e27acSAndrew Rist  *************************************************************/
21*9d7e27acSAndrew Rist 
22*9d7e27acSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx"
26cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx>
27cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir using namespace ::rtl;
30cdf0e10cSrcweir using namespace ::com::sun::star::uno;
31cdf0e10cSrcweir using namespace ::com::sun::star::lang;
32cdf0e10cSrcweir using namespace ::com::sun::star::registry;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace cppu {
35cdf0e10cSrcweir 
component_writeInfoHelper(void *,void * pRegistryKey,const struct ImplementationEntry entries[])36cdf0e10cSrcweir sal_Bool component_writeInfoHelper(
37cdf0e10cSrcweir 	void *, void *pRegistryKey , const struct ImplementationEntry entries[] )
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
40cdf0e10cSrcweir 	try
41cdf0e10cSrcweir 	{
42cdf0e10cSrcweir 		if( pRegistryKey )
43cdf0e10cSrcweir 		{
44cdf0e10cSrcweir 			for( sal_Int32 i = 0; entries[i].create ; i ++ )
45cdf0e10cSrcweir 			{
46cdf0e10cSrcweir 				OUStringBuffer buf( 124 );
47cdf0e10cSrcweir 				buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/") );
48cdf0e10cSrcweir 				buf.append( entries[i].getImplementationName() );
49cdf0e10cSrcweir 				buf.appendAscii(RTL_CONSTASCII_STRINGPARAM( "/UNO/SERVICES" ) );
50cdf0e10cSrcweir 				Reference< XRegistryKey > xNewKey(
51cdf0e10cSrcweir 					reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( buf.makeStringAndClear()  ) );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 				Sequence< OUString > seq = entries[i].getSupportedServiceNames();
54cdf0e10cSrcweir 				const OUString *pArray = seq.getConstArray();
55cdf0e10cSrcweir 				for ( sal_Int32 nPos = 0 ; nPos < seq.getLength(); nPos ++ )
56cdf0e10cSrcweir 					xNewKey->createKey( pArray[nPos] );
57cdf0e10cSrcweir 			}
58cdf0e10cSrcweir 			bRet = sal_True;
59cdf0e10cSrcweir 		}
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir 	catch ( InvalidRegistryException & )
62cdf0e10cSrcweir 	{
63cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
64cdf0e10cSrcweir 	}
65cdf0e10cSrcweir 	return bRet;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
component_getFactoryHelper(const sal_Char * pImplName,void *,void *,const struct ImplementationEntry entries[])69cdf0e10cSrcweir void * component_getFactoryHelper(
70cdf0e10cSrcweir 	const sal_Char * pImplName, void *, void *,
71cdf0e10cSrcweir 	const struct ImplementationEntry entries[] )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 
74cdf0e10cSrcweir   	void * pRet = 0;
75cdf0e10cSrcweir 	Reference< XSingleComponentFactory > xFactory;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	for( sal_Int32 i = 0 ; entries[i].create ; i ++ )
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 		OUString implName = entries[i].getImplementationName();
80cdf0e10cSrcweir 		if( 0 == implName.compareToAscii( pImplName ) )
81cdf0e10cSrcweir 		{
82cdf0e10cSrcweir 			xFactory = entries[i].createFactory(
83cdf0e10cSrcweir 				entries[i].create,
84cdf0e10cSrcweir 				implName,
85cdf0e10cSrcweir 				entries[i].getSupportedServiceNames(),
86cdf0e10cSrcweir 				entries[i].moduleCounter );
87cdf0e10cSrcweir 		}
88cdf0e10cSrcweir 	}
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	if( xFactory.is() )
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir 		xFactory->acquire();
93cdf0e10cSrcweir 		pRet = xFactory.get();
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 	return pRet;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir }
99