diff options
author | Rüdiger Timm <rt@openoffice.org> | 2006-12-11 11:58:28 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2006-12-11 11:58:28 +0000 |
commit | 209b17495976a987861710c285d8d0df32909eb7 (patch) | |
tree | 29e38d1229a98005029a36173fbad3005349bc97 /cppuhelper/source | |
parent | db8723e9a5e55d136cb3a67cd931482bc2a1a6ef (diff) |
#i72372# Re-introduce some default regarding mappings for those places bridges are not (yet) available. Patch by KR.
Diffstat (limited to 'cppuhelper/source')
-rw-r--r-- | cppuhelper/source/shlib.cxx | 244 |
1 files changed, 146 insertions, 98 deletions
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx index 86718aedee68..67562c72c77d 100644 --- a/cppuhelper/source/shlib.cxx +++ b/cppuhelper/source/shlib.cxx @@ -4,9 +4,9 @@ * * $RCSfile: shlib.cxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.26 $ * - * last change: $Author: rt $ $Date: 2006-12-01 17:18:35 $ + * last change: $Author: rt $ $Date: 2006-12-11 12:58:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -311,7 +311,6 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( pSym = osl_getFunctionSymbol( lib, aGetEnvName.pData ); if (pSym != 0) { - uno_Environment * pCurrentEnv = 0; uno_Environment * pEnv = 0; const sal_Char * pEnvTypeName = 0; @@ -319,17 +318,6 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( &pEnvTypeName, &pEnv ); OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) ); - if (! pEnv) - { - uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 ); - } - if (pEnv) - { - OUString aCppEnvTypeName = - OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME); - uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 ); - } - OUString aGetFactoryName = OUSTR(COMPONENT_GETFACTORY); pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData ); if (pSym != 0) @@ -337,59 +325,97 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( OString aImplName( OUStringToOString( rImplName, RTL_TEXTENCODING_ASCII_US ) ); - if (pEnv && pCurrentEnv) + if (pEnv == NULL &&aEnvTypeName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME))) + { + XInterface * pRet = + (XInterface *) (*((component_getFactoryFunc) pSym))( + aImplName.getStr(), xMgr.get(), xKey.get() ); + if (pRet) + { + xRet = pRet; + pRet->release(); + } + else + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": cannot get factory of demanded " + "implementation: "); + aExcMsg += OStringToOUString( + aImplName, RTL_TEXTENCODING_ASCII_US ); + } + } + else { - Mapping aCurrent2Env( pCurrentEnv, pEnv ); - Mapping aEnv2Current( pEnv, pCurrentEnv ); + if (!pEnv) + uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 ); - if (aCurrent2Env.is() && aEnv2Current.is()) + uno_Environment * pCurrentEnv = 0; + if (pEnv) { - void * pSMgr = aCurrent2Env.mapInterface( - xMgr.get(), ::getCppuType( &xMgr ) ); - void * pKey = aCurrent2Env.mapInterface( - xKey.get(), ::getCppuType( &xKey ) ); + OUString aCppEnvTypeName = + OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME); + uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 ); + } - void * pSSF = - (*((component_getFactoryFunc) pSym))( - aImplName.getStr(), pSMgr, pKey ); - if (pKey) - { - (*pEnv->pExtEnv->releaseInterface)( - pEnv->pExtEnv, pKey ); - } - if (pSMgr) - { - (*pEnv->pExtEnv->releaseInterface)( - pEnv->pExtEnv, pSMgr ); - } + if (pEnv && pCurrentEnv) + { + Mapping aCurrent2Env( pCurrentEnv, pEnv ); + Mapping aEnv2Current( pEnv, pCurrentEnv ); - if (pSSF) + if (aCurrent2Env.is() && aEnv2Current.is()) { - aEnv2Current.mapInterface( - reinterpret_cast< void ** >( &xRet ), - pSSF, ::getCppuType( &xRet ) ); - (*pEnv->pExtEnv->releaseInterface)( - pEnv->pExtEnv, pSSF ); + void * pSMgr = aCurrent2Env.mapInterface( + xMgr.get(), ::getCppuType( &xMgr ) ); + void * pKey = aCurrent2Env.mapInterface( + xKey.get(), ::getCppuType( &xKey ) ); + + void * pSSF = + (*((component_getFactoryFunc) pSym))( + aImplName.getStr(), pSMgr, pKey ); + + if (pKey) + { + (*pEnv->pExtEnv->releaseInterface)( + pEnv->pExtEnv, pKey ); + } + if (pSMgr) + { + (*pEnv->pExtEnv->releaseInterface)( + pEnv->pExtEnv, pSMgr ); + } + + if (pSSF) + { + aEnv2Current.mapInterface( + reinterpret_cast< void ** >( &xRet ), + pSSF, ::getCppuType( &xRet ) ); + (*pEnv->pExtEnv->releaseInterface)( + pEnv->pExtEnv, pSSF ); + } + else + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": cannot get factory of " + "demanded implementation: "); + aExcMsg += OStringToOUString( + aImplName, RTL_TEXTENCODING_ASCII_US ); + } } else { - aExcMsg = aModulePath; - aExcMsg += OUSTR(": cannot get factory of " - "demanded implementation: "); - aExcMsg += OStringToOUString( - aImplName, RTL_TEXTENCODING_ASCII_US ); + aExcMsg = + OUSTR("cannot get uno mappings: C++ <=> UNO!"); } } else { - aExcMsg = - OUSTR("cannot get uno mappings: C++ <=> UNO!"); + aExcMsg = OUSTR("cannot get uno environments!"); } - } - else - { - aExcMsg = OUSTR("cannot get uno environments!"); + + if (pCurrentEnv) + (*pCurrentEnv->release)( pCurrentEnv ); } } else @@ -401,8 +427,6 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( if (pEnv) (*pEnv->release)( pEnv ); - if (pCurrentEnv) - (*pCurrentEnv->release)( pCurrentEnv ); } else { @@ -463,7 +487,6 @@ void SAL_CALL writeSharedLibComponentInfo( pSym = osl_getFunctionSymbol( lib, aGetEnvName.pData ); if (pSym != 0) { - uno_Environment * pCurrentEnv = 0; uno_Environment * pEnv = 0; const sal_Char * pEnvTypeName = 0; @@ -471,65 +494,92 @@ void SAL_CALL writeSharedLibComponentInfo( &pEnvTypeName, &pEnv ); OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) ); - if (! pEnv) - { - uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 ); - } - if (pEnv) - { - OUString aCppEnvTypeName = - OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME); - uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 ); - } - OUString aWriteInfoName = OUSTR(COMPONENT_WRITEINFO); pSym = osl_getFunctionSymbol( lib, aWriteInfoName.pData ); if (pSym != 0) { - if (pEnv && pCurrentEnv) + if (pEnv == NULL && aEnvTypeName.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME))) { - Mapping aCurrent2Env( pCurrentEnv, pEnv ); - if (aCurrent2Env.is()) + if (xKey.is()) { - void * pSMgr = aCurrent2Env.mapInterface( - xMgr.get(), ::getCppuType( &xMgr ) ); - void * pKey = aCurrent2Env.mapInterface( - xKey.get(), ::getCppuType( &xKey ) ); - if (pKey) + bRet = (*((component_writeInfoFunc) pSym))( + xMgr.get(), xKey.get() ); + if (! bRet) { - bRet = (*((component_writeInfoFunc) pSym))( - pSMgr, pKey ); - (*pEnv->pExtEnv->releaseInterface)( - pEnv->pExtEnv, pKey ); - if (! bRet) + aExcMsg = aModulePath; + aExcMsg += OUSTR(": component_writeInfo() returned " + "false!"); + } + } + else + { + // key is mandatory + aExcMsg = aModulePath; + aExcMsg += OUSTR(": registry is mandatory to invoke " + "component_writeInfo()!"); + } + } + else + { + if (!pEnv) + uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 ); + + uno_Environment * pCurrentEnv = 0; + if (pEnv) + { + OUString aCppEnvTypeName = + OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME); + uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 ); + } + + if (pEnv && pCurrentEnv) + { + Mapping aCurrent2Env( pCurrentEnv, pEnv ); + if (aCurrent2Env.is()) + { + void * pSMgr = aCurrent2Env.mapInterface( + xMgr.get(), ::getCppuType( &xMgr ) ); + void * pKey = aCurrent2Env.mapInterface( + xKey.get(), ::getCppuType( &xKey ) ); + if (pKey) { + bRet = (*((component_writeInfoFunc) pSym))( + pSMgr, pKey ); + (*pEnv->pExtEnv->releaseInterface)( + pEnv->pExtEnv, pKey ); + if (! bRet) + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": component_writeInfo() " + "returned false!"); + } + } + else + { + // key is mandatory aExcMsg = aModulePath; - aExcMsg += OUSTR(": component_writeInfo() " - "returned false!"); + aExcMsg += OUSTR(": registry is mandatory to invoke" + " component_writeInfo()!"); + } + + if (pSMgr) + { + (*pEnv->pExtEnv->releaseInterface)( + pEnv->pExtEnv, pSMgr ); } } else { - // key is mandatory - aExcMsg = aModulePath; - aExcMsg += OUSTR(": registry is mandatory to invoke" - " component_writeInfo()!"); - } - - if (pSMgr) - { - (*pEnv->pExtEnv->releaseInterface)( - pEnv->pExtEnv, pSMgr ); + aExcMsg = OUSTR("cannot get uno mapping: C++ <=> UNO!"); } } else { - aExcMsg = OUSTR("cannot get uno mapping: C++ <=> UNO!"); + aExcMsg = OUSTR("cannot get uno environments!"); } - } - else - { - aExcMsg = OUSTR("cannot get uno environments!"); + if (pCurrentEnv) + (*pCurrentEnv->release)( pCurrentEnv ); } } else @@ -541,8 +591,6 @@ void SAL_CALL writeSharedLibComponentInfo( if (pEnv) (*pEnv->release)( pEnv ); - if (pCurrentEnv) - (*pCurrentEnv->release)( pCurrentEnv ); } else { |