Shortcut common case of calling same-env component_getFactory fn

Change-Id: I7f5d31c3b3e128b2df4d83c915673bf7b5d2ab8c
This commit is contained in:
Stephan Bergmann
2013-12-13 16:18:52 +01:00
parent d203855908
commit a4ed79bbf6

View File

@@ -188,46 +188,56 @@ Reference< XInterface > invokeComponentFactory(
fprintf(stderr, "invokeComponentFactory envDcp:%s implName:%s modPath:%s\n", envDcp.getStr(), implName.getStr(), modPath.getStr()); fprintf(stderr, "invokeComponentFactory envDcp:%s implName:%s modPath:%s\n", envDcp.getStr(), implName.getStr(), modPath.getStr());
} }
#endif #endif
if (env.get() == currentEnv.get())
Mapping aCurrent2Env( currentEnv, env );
Mapping aEnv2Current( env, currentEnv );
if (aCurrent2Env.is() && aEnv2Current.is())
{ {
void * pSMgr = aCurrent2Env.mapInterface( xRet.set(
xMgr.get(), ::getCppuType( &xMgr ) ); static_cast<css::uno::XInterface *>(
(*reinterpret_cast<component_getFactoryFunc>(pGetter))(
void * pSSF = NULL; aImplName.getStr(), xMgr.get(), 0)),
SAL_NO_ACQUIRE);
env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
if (pSMgr)
{
(*env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pSMgr );
}
if (pSSF)
{
aEnv2Current.mapInterface(
reinterpret_cast< void ** >( &xRet ),
pSSF, ::getCppuType( &xRet ) );
(env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pSSF );
}
else
{
rExcMsg = rModulePath +
": cannot get factory of " +
"demanded implementation: " +
OStringToOUString(
aImplName, RTL_TEXTENCODING_ASCII_US );
}
} }
else else
{ {
rExcMsg = Mapping aCurrent2Env( currentEnv, env );
"cannot get uno mappings: C++ <=> UNO!"; Mapping aEnv2Current( env, currentEnv );
if (aCurrent2Env.is() && aEnv2Current.is())
{
void * pSMgr = aCurrent2Env.mapInterface(
xMgr.get(), ::getCppuType( &xMgr ) );
void * pSSF = NULL;
env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
if (pSMgr)
{
(*env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pSMgr );
}
if (pSSF)
{
aEnv2Current.mapInterface(
reinterpret_cast< void ** >( &xRet ),
pSSF, ::getCppuType( &xRet ) );
(env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pSSF );
}
else
{
rExcMsg = rModulePath +
": cannot get factory of " +
"demanded implementation: " +
OStringToOUString(
aImplName, RTL_TEXTENCODING_ASCII_US );
}
}
else
{
rExcMsg =
"cannot get uno mappings: C++ <=> UNO!";
}
} }
} }
else else