1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testfactreg.cxx,v $
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_io.hxx"
36 #include <osl/diagnose.h>
38 #include <cppuhelper/factory.hxx> // for EXTERN_SERVICE_CALLTYPE
40 using namespace ::rtl
;
41 using namespace ::cppu
;
42 using namespace ::com::sun::star::registry
;
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::lang
;
46 #include "testfactreg.hxx"
52 void SAL_CALL
component_getImplementationEnvironment(
53 const sal_Char
** ppEnvTypeName
, uno_Environment
** ppEnv
)
55 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
59 sal_Bool SAL_CALL
component_writeInfo(
60 void * pServiceManager
, void * pRegistryKey
)
66 Reference
< XRegistryKey
> xKey(
67 reinterpret_cast< XRegistryKey
* >( pRegistryKey
) );
69 OUString str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
70 OPipeTest_getImplementationName() +
71 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
72 Reference
< XRegistryKey
> xNewKey
= xKey
->createKey( str
);
73 xNewKey
->createKey( OPipeTest_getServiceName() );
75 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
76 OPumpTest_getImplementationName() +
77 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
78 xNewKey
= xKey
->createKey( str
);
79 xNewKey
->createKey( OPumpTest_getServiceName() );
81 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
82 ODataStreamTest_getImplementationName(1) +
83 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
84 xNewKey
= xKey
->createKey( str
);
85 xNewKey
->createKey( ODataStreamTest_getServiceName(1) );
87 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
88 ODataStreamTest_getImplementationName(2) +
89 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
90 xNewKey
= xKey
->createKey( str
);
91 xNewKey
->createKey( ODataStreamTest_getServiceName(2) );
93 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
94 OObjectStreamTest_getImplementationName(1) +
95 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
96 xNewKey
= xKey
->createKey( str
);
97 xNewKey
->createKey( OObjectStreamTest_getServiceName(1) );
99 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
100 OObjectStreamTest_getImplementationName(2) +
101 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
102 xNewKey
= xKey
->createKey( str
);
103 xNewKey
->createKey( OObjectStreamTest_getServiceName(2) );
105 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
106 OMarkableOutputStreamTest_getImplementationName() +
107 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
108 xNewKey
= xKey
->createKey( str
);
109 xNewKey
->createKey( OMarkableOutputStreamTest_getServiceName() );
111 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
112 OMarkableInputStreamTest_getImplementationName() +
113 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
114 xNewKey
= xKey
->createKey( str
);
115 xNewKey
->createKey( OMarkableInputStreamTest_getServiceName() );
117 str
= OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
118 OMyPersistObject_getImplementationName() +
119 OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") );
120 xNewKey
= xKey
->createKey( str
);
121 xNewKey
->createKey( OMyPersistObject_getServiceName() );
125 catch (InvalidRegistryException
&)
127 OSL_ENSURE( sal_False
, "### InvalidRegistryException!" );
133 void * SAL_CALL
component_getFactory(
134 const sal_Char
* pImplName
, void * pServiceManager
, void * pRegistryKey
)
138 if (pServiceManager
)
140 Reference
< XSingleServiceFactory
> xRet
;
141 Reference
< XMultiServiceFactory
> xSMgr
=
142 reinterpret_cast< XMultiServiceFactory
* > ( pServiceManager
);
144 OUString aImplementationName
= OUString::createFromAscii( pImplName
);
146 if (aImplementationName
== OPipeTest_getImplementationName() )
148 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
149 OPipeTest_CreateInstance
,
150 OPipeTest_getSupportedServiceNames() );
152 else if (aImplementationName
== OPumpTest_getImplementationName() )
154 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
155 OPumpTest_CreateInstance
,
156 OPumpTest_getSupportedServiceNames() );
159 else if( aImplementationName
== ODataStreamTest_getImplementationName(1) ) {
160 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
161 ODataStreamTest_CreateInstance
,
162 ODataStreamTest_getSupportedServiceNames(1) );
164 else if( aImplementationName
== ODataStreamTest_getImplementationName(2) ) {
165 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
166 ODataStreamTest_CreateInstance
,
167 ODataStreamTest_getSupportedServiceNames(2) );
169 else if( aImplementationName
== OObjectStreamTest_getImplementationName(1) ) {
170 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
171 OObjectStreamTest_CreateInstance
,
172 OObjectStreamTest_getSupportedServiceNames(1) );
174 else if( aImplementationName
== OObjectStreamTest_getImplementationName(2) ) {
175 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
176 OObjectStreamTest_CreateInstance
,
177 OObjectStreamTest_getSupportedServiceNames(2) );
179 else if( aImplementationName
== OMarkableOutputStreamTest_getImplementationName() ) {
180 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
181 OMarkableOutputStreamTest_CreateInstance
,
182 OMarkableOutputStreamTest_getSupportedServiceNames() );
184 else if( aImplementationName
== OMarkableInputStreamTest_getImplementationName() ) {
185 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
186 OMarkableInputStreamTest_CreateInstance
,
187 OMarkableInputStreamTest_getSupportedServiceNames() );
189 else if( aImplementationName
== OMyPersistObject_getImplementationName() ) {
190 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
191 OMyPersistObject_CreateInstance
,
192 OMyPersistObject_getSupportedServiceNames() );
206 Sequence
<sal_Int8
> createSeq( char * p
)
208 Sequence
<sal_Int8
> seq( strlen( p
)+1 );
209 strcpy( (char * ) seq
.getArray() , p
);
213 Sequence
<sal_Int8
> createIntSeq( sal_Int32 i
)
216 sprintf( pcCount
, "%d" , i
);
217 return createSeq( pcCount
);