Bump version to 6.4-15
[LibreOffice.git] / io / test / stm / testfactreg.cxx
blob1a409e929a4adefd49e29fb71c94f2f14f9f13b4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <stdio.h>
21 #include <string.h>
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"
35 extern "C"
38 sal_Bool SAL_CALL component_writeInfo(
39 void * pServiceManager, void * pRegistryKey )
41 if (pRegistryKey)
43 try
45 Reference< XRegistryKey > xKey(
46 reinterpret_cast< XRegistryKey * >( pRegistryKey ) );
48 OUString str = "/" +
49 OPipeTest_getImplementationName() +
50 "/UNO/SERVICES";
51 Reference< XRegistryKey > xNewKey = xKey->createKey( str );
52 xNewKey->createKey( OPipeTest_getServiceName() );
54 str = "/" +
55 OPumpTest_getImplementationName() +
56 "/UNO/SERVICES";
57 xNewKey = xKey->createKey( str );
58 xNewKey->createKey( OPumpTest_getServiceName() );
60 str = "/" +
61 ODataStreamTest_getImplementationName(1) +
62 "/UNO/SERVICES";
63 xNewKey = xKey->createKey( str );
64 xNewKey->createKey( ODataStreamTest_getServiceName(1) );
66 str = "/" +
67 ODataStreamTest_getImplementationName(2) +
68 "/UNO/SERVICES";
69 xNewKey = xKey->createKey( str );
70 xNewKey->createKey( ODataStreamTest_getServiceName(2) );
72 str = "/" +
73 OObjectStreamTest_getImplementationName(1) +
74 "/UNO/SERVICES";
75 xNewKey = xKey->createKey( str );
76 xNewKey->createKey( OObjectStreamTest_getServiceName(1) );
78 str = "/" +
79 OObjectStreamTest_getImplementationName(2) +
80 "/UNO/SERVICES";
81 xNewKey = xKey->createKey( str );
82 xNewKey->createKey( OObjectStreamTest_getServiceName(2) );
84 str = "/" +
85 OMarkableOutputStreamTest_getImplementationName() +
86 "/UNO/SERVICES";
87 xNewKey = xKey->createKey( str );
88 xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() );
90 str = "/" +
91 OMarkableInputStreamTest_getImplementationName() +
92 "/UNO/SERVICES";
93 xNewKey = xKey->createKey( str );
94 xNewKey->createKey( OMarkableInputStreamTest_getServiceName() );
96 str = "/" +
97 OMyPersistObject_getImplementationName() +
98 "/UNO/SERVICES";
99 xNewKey = xKey->createKey( str );
100 xNewKey->createKey( OMyPersistObject_getServiceName() );
102 return sal_True;
104 catch (InvalidRegistryException &)
106 OSL_FAIL( "### InvalidRegistryException!" );
109 return sal_False;
112 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
113 const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
115 void * pRet = 0;
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() );
173 if (xRet.is())
175 xRet->acquire();
176 pRet = xRet.get();
180 return pRet;
185 Sequence<sal_Int8 > createSeq( char * p )
187 Sequence<sal_Int8> seq( strlen( p )+1 );
188 strcpy( (char * ) seq.getArray() , p );
189 return seq;
192 Sequence<sal_Int8> createIntSeq( sal_Int32 i )
194 char pcCount[20];
195 sprintf( pcCount , "%d" , i );
196 return createSeq( pcCount );
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */