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>
27 using namespace ::cppu
;
28 using namespace ::com::sun::star::registry
;
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::lang
;
32 #include "testfactreg.hxx"
38 sal_Bool SAL_CALL
component_writeInfo(
39 void * pServiceManager
, void * pRegistryKey
)
45 Reference
< XRegistryKey
> xKey(
46 reinterpret_cast< XRegistryKey
* >( pRegistryKey
) );
49 OPipeTest_getImplementationName() +
51 Reference
< XRegistryKey
> xNewKey
= xKey
->createKey( str
);
52 xNewKey
->createKey( OPipeTest_getServiceName() );
55 OPumpTest_getImplementationName() +
57 xNewKey
= xKey
->createKey( str
);
58 xNewKey
->createKey( OPumpTest_getServiceName() );
61 ODataStreamTest_getImplementationName(1) +
63 xNewKey
= xKey
->createKey( str
);
64 xNewKey
->createKey( ODataStreamTest_getServiceName(1) );
67 ODataStreamTest_getImplementationName(2) +
69 xNewKey
= xKey
->createKey( str
);
70 xNewKey
->createKey( ODataStreamTest_getServiceName(2) );
73 OObjectStreamTest_getImplementationName(1) +
75 xNewKey
= xKey
->createKey( str
);
76 xNewKey
->createKey( OObjectStreamTest_getServiceName(1) );
79 OObjectStreamTest_getImplementationName(2) +
81 xNewKey
= xKey
->createKey( str
);
82 xNewKey
->createKey( OObjectStreamTest_getServiceName(2) );
85 OMarkableOutputStreamTest_getImplementationName() +
87 xNewKey
= xKey
->createKey( str
);
88 xNewKey
->createKey( OMarkableOutputStreamTest_getServiceName() );
91 OMarkableInputStreamTest_getImplementationName() +
93 xNewKey
= xKey
->createKey( str
);
94 xNewKey
->createKey( OMarkableInputStreamTest_getServiceName() );
97 OMyPersistObject_getImplementationName() +
99 xNewKey
= xKey
->createKey( str
);
100 xNewKey
->createKey( OMyPersistObject_getServiceName() );
104 catch (InvalidRegistryException
&)
106 OSL_FAIL( "### InvalidRegistryException!" );
112 SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory(
113 const char * pImplName
, void * pServiceManager
, void * pRegistryKey
)
117 if (pServiceManager
)
119 Reference
< XSingleServiceFactory
> xRet
;
120 Reference
< XMultiServiceFactory
> xSMgr
=
121 reinterpret_cast< XMultiServiceFactory
* > ( pServiceManager
);
123 OUString aImplementationName
= OUString::createFromAscii( pImplName
);
125 if (aImplementationName
== OPipeTest_getImplementationName() )
127 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
128 OPipeTest_CreateInstance
,
129 OPipeTest_getSupportedServiceNames() );
131 else if (aImplementationName
== OPumpTest_getImplementationName() )
133 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
134 OPumpTest_CreateInstance
,
135 OPumpTest_getSupportedServiceNames() );
138 else if( aImplementationName
== ODataStreamTest_getImplementationName(1) ) {
139 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
140 ODataStreamTest_CreateInstance
,
141 ODataStreamTest_getSupportedServiceNames(1) );
143 else if( aImplementationName
== ODataStreamTest_getImplementationName(2) ) {
144 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
145 ODataStreamTest_CreateInstance
,
146 ODataStreamTest_getSupportedServiceNames(2) );
148 else if( aImplementationName
== OObjectStreamTest_getImplementationName(1) ) {
149 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
150 OObjectStreamTest_CreateInstance
,
151 OObjectStreamTest_getSupportedServiceNames(1) );
153 else if( aImplementationName
== OObjectStreamTest_getImplementationName(2) ) {
154 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
155 OObjectStreamTest_CreateInstance
,
156 OObjectStreamTest_getSupportedServiceNames(2) );
158 else if( aImplementationName
== OMarkableOutputStreamTest_getImplementationName() ) {
159 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
160 OMarkableOutputStreamTest_CreateInstance
,
161 OMarkableOutputStreamTest_getSupportedServiceNames() );
163 else if( aImplementationName
== OMarkableInputStreamTest_getImplementationName() ) {
164 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
165 OMarkableInputStreamTest_CreateInstance
,
166 OMarkableInputStreamTest_getSupportedServiceNames() );
168 else if( aImplementationName
== OMyPersistObject_getImplementationName() ) {
169 xRet
= createSingleFactory( xSMgr
, aImplementationName
,
170 OMyPersistObject_CreateInstance
,
171 OMyPersistObject_getSupportedServiceNames() );
185 Sequence
<sal_Int8
> createSeq( char * p
)
187 Sequence
<sal_Int8
> seq( strlen( p
)+1 );
188 strcpy( (char * ) seq
.getArray() , p
);
192 Sequence
<sal_Int8
> createIntSeq( sal_Int32 i
)
195 sprintf( pcCount
, "%d" , i
);
196 return createSeq( pcCount
);
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */