1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_io.hxx" 30*cdf0e10cSrcweir #include <stdio.h> 31*cdf0e10cSrcweir #include <string.h> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <osl/diagnose.h> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <cppuhelper/factory.hxx> // for EXTERN_SERVICE_CALLTYPE 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using namespace ::rtl; 38*cdf0e10cSrcweir using namespace ::cppu; 39*cdf0e10cSrcweir using namespace ::com::sun::star::registry; 40*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 41*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include "testfactreg.hxx" 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir extern "C" 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment( 50*cdf0e10cSrcweir const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir sal_Bool SAL_CALL component_writeInfo( 57*cdf0e10cSrcweir void * pServiceManager, void * pRegistryKey ) 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir if (pRegistryKey) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir try 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir Reference< XRegistryKey > xKey( 64*cdf0e10cSrcweir reinterpret_cast< XRegistryKey * >( pRegistryKey ) ); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir OUString str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 67*cdf0e10cSrcweir OPipeTest_getImplementationName() + 68*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 69*cdf0e10cSrcweir Reference< XRegistryKey > xNewKey = xKey->createKey( str ); 70*cdf0e10cSrcweir xNewKey->createKey( OPipeTest_getServiceName() ); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 73*cdf0e10cSrcweir OPumpTest_getImplementationName() + 74*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 75*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 76*cdf0e10cSrcweir xNewKey->createKey( OPumpTest_getServiceName() ); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 79*cdf0e10cSrcweir ODataStreamTest_getImplementationName(1) + 80*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 81*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 82*cdf0e10cSrcweir xNewKey->createKey( ODataStreamTest_getServiceName(1) ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 85*cdf0e10cSrcweir ODataStreamTest_getImplementationName(2) + 86*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 87*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 88*cdf0e10cSrcweir xNewKey->createKey( ODataStreamTest_getServiceName(2) ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 91*cdf0e10cSrcweir OObjectStreamTest_getImplementationName(1) + 92*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 93*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 94*cdf0e10cSrcweir xNewKey->createKey( OObjectStreamTest_getServiceName(1) ); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 97*cdf0e10cSrcweir OObjectStreamTest_getImplementationName(2) + 98*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 99*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 100*cdf0e10cSrcweir xNewKey->createKey( OObjectStreamTest_getServiceName(2) ); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 103*cdf0e10cSrcweir OMarkableOutputStreamTest_getImplementationName() + 104*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 105*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 106*cdf0e10cSrcweir xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 109*cdf0e10cSrcweir OMarkableInputStreamTest_getImplementationName() + 110*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 111*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 112*cdf0e10cSrcweir xNewKey->createKey( OMarkableInputStreamTest_getServiceName() ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir str = OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + 115*cdf0e10cSrcweir OMyPersistObject_getImplementationName() + 116*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ); 117*cdf0e10cSrcweir xNewKey = xKey->createKey( str ); 118*cdf0e10cSrcweir xNewKey->createKey( OMyPersistObject_getServiceName() ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir return sal_True; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir catch (InvalidRegistryException &) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir return sal_False; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir void * SAL_CALL component_getFactory( 131*cdf0e10cSrcweir const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir void * pRet = 0; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir if (pServiceManager ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir Reference< XSingleServiceFactory > xRet; 138*cdf0e10cSrcweir Reference< XMultiServiceFactory > xSMgr = 139*cdf0e10cSrcweir reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir OUString aImplementationName = OUString::createFromAscii( pImplName ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if (aImplementationName == OPipeTest_getImplementationName() ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr, aImplementationName, 146*cdf0e10cSrcweir OPipeTest_CreateInstance, 147*cdf0e10cSrcweir OPipeTest_getSupportedServiceNames() ); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir else if (aImplementationName == OPumpTest_getImplementationName() ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr, aImplementationName, 152*cdf0e10cSrcweir OPumpTest_CreateInstance, 153*cdf0e10cSrcweir OPumpTest_getSupportedServiceNames() ); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) { 157*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 158*cdf0e10cSrcweir ODataStreamTest_CreateInstance, 159*cdf0e10cSrcweir ODataStreamTest_getSupportedServiceNames(1) ); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) { 162*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 163*cdf0e10cSrcweir ODataStreamTest_CreateInstance, 164*cdf0e10cSrcweir ODataStreamTest_getSupportedServiceNames(2) ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) { 167*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 168*cdf0e10cSrcweir OObjectStreamTest_CreateInstance, 169*cdf0e10cSrcweir OObjectStreamTest_getSupportedServiceNames(1) ); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) { 172*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 173*cdf0e10cSrcweir OObjectStreamTest_CreateInstance, 174*cdf0e10cSrcweir OObjectStreamTest_getSupportedServiceNames(2) ); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) { 177*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 178*cdf0e10cSrcweir OMarkableOutputStreamTest_CreateInstance, 179*cdf0e10cSrcweir OMarkableOutputStreamTest_getSupportedServiceNames() ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) { 182*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 183*cdf0e10cSrcweir OMarkableInputStreamTest_CreateInstance, 184*cdf0e10cSrcweir OMarkableInputStreamTest_getSupportedServiceNames() ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir else if( aImplementationName == OMyPersistObject_getImplementationName() ) { 187*cdf0e10cSrcweir xRet = createSingleFactory( xSMgr , aImplementationName, 188*cdf0e10cSrcweir OMyPersistObject_CreateInstance, 189*cdf0e10cSrcweir OMyPersistObject_getSupportedServiceNames() ); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir if (xRet.is()) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir xRet->acquire(); 194*cdf0e10cSrcweir pRet = xRet.get(); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir return pRet; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir Sequence<sal_Int8 > createSeq( char * p ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir Sequence<sal_Int8> seq( strlen( p )+1 ); 206*cdf0e10cSrcweir strcpy( (char * ) seq.getArray() , p ); 207*cdf0e10cSrcweir return seq; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir Sequence<sal_Int8> createIntSeq( sal_Int32 i ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir char pcCount[20]; 213*cdf0e10cSrcweir sprintf( pcCount , "%d" , i ); 214*cdf0e10cSrcweir return createSeq( pcCount ); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217