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