1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <osl/diagnose.h>
25 #include <cppuhelper/factory.hxx> // for EXTERN_SERVICE_CALLTYPE
27 using namespace ::rtl
;
28 using namespace ::cppu
;
29 using namespace ::com::sun::star::registry
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::lang
;
33 #include "testfactreg.hxx"
39 sal_Bool SAL_CALL
component_writeInfo(
40 void * pServiceManager
, void * pRegistryKey
)
46 Reference
< XRegistryKey
> xKey(
47 reinterpret_cast< XRegistryKey
* >( pRegistryKey
) );
49 OUString str
= OUString("/") +
50 OPipeTest_getImplementationName() +
51 OUString("/UNO/SERVICES");
52 Reference
< XRegistryKey
> xNewKey
= xKey
->createKey( str
);
53 xNewKey
->createKey( OPipeTest_getServiceName() );
56 OPumpTest_getImplementationName() +
57 OUString("/UNO/SERVICES");
58 xNewKey
= xKey
->createKey( str
);
59 xNewKey
->createKey( OPumpTest_getServiceName() );
62 ODataStreamTest_getImplementationName(1) +
63 OUString("/UNO/SERVICES");
64 xNewKey
= xKey
->createKey( str
);
65 xNewKey
->createKey( ODataStreamTest_getServiceName(1) );
68 ODataStreamTest_getImplementationName(2) +
69 OUString("/UNO/SERVICES");
70 xNewKey
= xKey
->createKey( str
);
71 xNewKey
->createKey( ODataStreamTest_getServiceName(2) );
74 OObjectStreamTest_getImplementationName(1) +
75 OUString("/UNO/SERVICES");
76 xNewKey
= xKey
->createKey( str
);
77 xNewKey
->createKey( OObjectStreamTest_getServiceName(1) );
80 OObjectStreamTest_getImplementationName(2) +
81 OUString("/UNO/SERVICES");
82 xNewKey
= xKey
->createKey( str
);
83 xNewKey
->createKey( OObjectStreamTest_getServiceName(2) );
86 OMarkableOutputStreamTest_getImplementationName() +
87 OUString("/UNO/SERVICES");
88 xNewKey
= xKey
->createKey( str
);
89 xNewKey
->createKey( OMarkableOutputStreamTest_getServiceName() );
92 OMarkableInputStreamTest_getImplementationName() +
93 OUString("/UNO/SERVICES");
94 xNewKey
= xKey
->createKey( str
);
95 xNewKey
->createKey( OMarkableInputStreamTest_getServiceName() );
98 OMyPersistObject_getImplementationName() +
99 OUString("/UNO/SERVICES");
100 xNewKey
= xKey
->createKey( str
);
101 xNewKey
->createKey( OMyPersistObject_getServiceName() );
105 catch (InvalidRegistryException
&)
107 OSL_FAIL( "### InvalidRegistryException!" );
113 SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory(
114 const sal_Char
* pImplName
, void * pServiceManager
, void * pRegistryKey
)
118 if (pServiceManager
)
120 Reference
< XSingleServiceFactory
> xRet
;
121 Reference
< XMultiServiceFactory
> xSMgr
=
122 reinterpret_cast< XMultiServiceFactory
* > ( pServiceManager
);
124 OUString aImplementationName
= OUString::createFromAscii( pImplName
);
126 if (aImplementationName
== OPipeTest_getImplementationName() )
128 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
129 OPipeTest_CreateInstance
,
130 OPipeTest_getSupportedServiceNames() );
132 else if (aImplementationName
== OPumpTest_getImplementationName() )
134 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
135 OPumpTest_CreateInstance
,
136 OPumpTest_getSupportedServiceNames() );
139 else if( aImplementationName
== ODataStreamTest_getImplementationName(1) ) {
140 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
141 ODataStreamTest_CreateInstance
,
142 ODataStreamTest_getSupportedServiceNames(1) );
144 else if( aImplementationName
== ODataStreamTest_getImplementationName(2) ) {
145 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
146 ODataStreamTest_CreateInstance
,
147 ODataStreamTest_getSupportedServiceNames(2) );
149 else if( aImplementationName
== OObjectStreamTest_getImplementationName(1) ) {
150 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
151 OObjectStreamTest_CreateInstance
,
152 OObjectStreamTest_getSupportedServiceNames(1) );
154 else if( aImplementationName
== OObjectStreamTest_getImplementationName(2) ) {
155 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
156 OObjectStreamTest_CreateInstance
,
157 OObjectStreamTest_getSupportedServiceNames(2) );
159 else if( aImplementationName
== OMarkableOutputStreamTest_getImplementationName() ) {
160 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
161 OMarkableOutputStreamTest_CreateInstance
,
162 OMarkableOutputStreamTest_getSupportedServiceNames() );
164 else if( aImplementationName
== OMarkableInputStreamTest_getImplementationName() ) {
165 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
166 OMarkableInputStreamTest_CreateInstance
,
167 OMarkableInputStreamTest_getSupportedServiceNames() );
169 else if( aImplementationName
== OMyPersistObject_getImplementationName() ) {
170 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
171 OMyPersistObject_CreateInstance
,
172 OMyPersistObject_getSupportedServiceNames() );
186 Sequence
<sal_Int8
> createSeq( char * p
)
188 Sequence
<sal_Int8
> seq( strlen( p
)+1 );
189 strcpy( (char * ) seq
.getArray() , p
);
193 Sequence
<sal_Int8
> createIntSeq( sal_Int32 i
)
196 sprintf( pcCount
, "%d" , i
);
197 return createSeq( pcCount
);
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */