xref: /AOO41X/main/extensions/test/stm/testfactreg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include <string.h>
31 
32 #include <usr/reflserv.hxx>  // for EXTERN_SERVICE_CALLTYPE
33 
34 #include <usr/factoryhlp.hxx>
35 #include "testfactreg.hxx"
36 
37 
38 using namespace vos;
39 using namespace usr;
40 
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45 
46 BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry(
47         const UNO_INTERFACE(XRegistryKey)* xUnoKey)
48 
49 {
50 	XRegistryKeyRef   xKey;
51 	uno2smart(xKey, *xUnoKey);
52 
53 	UString str = UString( L"/" ) + OPipeTest_getImplementationName() + UString( L"/UNO/SERVICES" );
54 	XRegistryKeyRef xNewKey = xKey->createKey( str );
55 	xNewKey->createKey( OPipeTest_getServiceName() );
56 
57 	str = UString( L"/" ) + ODataStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
58 	xNewKey = xKey->createKey( str );
59 	xNewKey->createKey( ODataStreamTest_getServiceName(1) );
60 
61 	str = UString( L"/" ) + ODataStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
62 	xNewKey = xKey->createKey( str );
63 	xNewKey->createKey( ODataStreamTest_getServiceName(2) );
64 
65 	str = UString( L"/" ) + OObjectStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
66 	xNewKey = xKey->createKey( str );
67 	xNewKey->createKey( OObjectStreamTest_getServiceName(1) );
68 
69 	str = UString( L"/" ) + OObjectStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
70 	xNewKey = xKey->createKey( str );
71 	xNewKey->createKey( OObjectStreamTest_getServiceName(2) );
72 
73 	str = UString( L"/" ) + OMarkableOutputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
74 	xNewKey = xKey->createKey( str );
75 	xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() );
76 
77 	str = UString( L"/" ) + OMarkableInputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
78 	xNewKey = xKey->createKey( str );
79 	xNewKey->createKey( OMarkableInputStreamTest_getServiceName() );
80 
81 	str = UString( L"/" ) + OMyPersistObject_getImplementationName() + UString( L"/UNO/SERVICES" );
82 	xNewKey = xKey->createKey( str );
83 	xNewKey->createKey( OMyPersistObject_getServiceName() );
84 
85 	return TRUE;
86 }
87 
88 
89 UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory
90 (
91 	const wchar_t* implementationName,
92 	const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact,
93 	const UNO_INTERFACE(XRegistryKey)*
94 )
95 {
96 	UNO_INTERFACE(XInterface) xUnoRet = {0, 0};
97 
98 	XInterfaceRef 			xRet;
99 	XMultiServiceFactoryRef xSMgr;
100 	UString					aImplementationName(implementationName);
101 
102 	uno2smart(xSMgr, *xUnoFact);
103 
104 	if (aImplementationName == OPipeTest_getImplementationName() )
105 	{
106 		xRet = createSingleFactory( xSMgr, implementationName,
107 									OPipeTest_CreateInstance,
108 									OPipeTest_getSupportedServiceNames() );
109 	}
110 	else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) {
111 		xRet = createSingleFactory( xSMgr , implementationName,
112 									ODataStreamTest_CreateInstance,
113 									ODataStreamTest_getSupportedServiceNames(1) );
114 	}
115 	else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) {
116 		xRet = createSingleFactory( xSMgr , implementationName,
117 									ODataStreamTest_CreateInstance,
118 									ODataStreamTest_getSupportedServiceNames(2) );
119 	}
120 	else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) {
121 		xRet = createSingleFactory( xSMgr , implementationName,
122 									OObjectStreamTest_CreateInstance,
123 									OObjectStreamTest_getSupportedServiceNames(1) );
124 	}
125 	else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) {
126 		xRet = createSingleFactory( xSMgr , implementationName,
127 									OObjectStreamTest_CreateInstance,
128 									OObjectStreamTest_getSupportedServiceNames(2) );
129 	}
130 	else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) {
131 		xRet = createSingleFactory( xSMgr , implementationName,
132 									OMarkableOutputStreamTest_CreateInstance,
133 									OMarkableOutputStreamTest_getSupportedServiceNames() );
134 	}
135 	else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) {
136 		xRet = createSingleFactory( xSMgr , implementationName,
137 									OMarkableInputStreamTest_CreateInstance,
138 									OMarkableInputStreamTest_getSupportedServiceNames() );
139 	}
140 	else if( aImplementationName == OMyPersistObject_getImplementationName() ) {
141 		xRet = createSingleFactory( xSMgr , implementationName,
142 									OMyPersistObject_CreateInstance,
143 									OMyPersistObject_getSupportedServiceNames() );
144 	}
145 	if (xRet.is())
146 	{
147 		smart2uno(xRet, xUnoRet);
148 	}
149 
150 	return xUnoRet;
151 }
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 Sequence<BYTE> createSeq( char * p )
158 {
159 	Sequence<BYTE> seq( strlen( p )+1 );
160 	strcpy( (char * ) seq.getArray() , p );
161 	return seq;
162 }
163 
164 Sequence<BYTE> createIntSeq( INT32 i )
165 {
166 	char pcCount[20];
167 	sprintf( pcCount , "%d" , i );
168 	return createSeq( pcCount );
169 }
170 
171