Allows using prefix information about component

This commit is contained in:
Matus Kukan 2011-06-16 17:01:51 +02:00 committed by Michael Meeks
parent 6e73ddbdd9
commit f1be5778f8
5 changed files with 36 additions and 7 deletions

View File

@ -48,6 +48,7 @@ namespace cppu
@param rImplName implementation to be retrieved from the library @param rImplName implementation to be retrieved from the library
@param xMgr service manager to be provided to the component @param xMgr service manager to be provided to the component
@param xKey registry key to be provided to the component @param xKey registry key to be provided to the component
@param rPrefix optional component prefix
@return @return
factory instance (::com::sun::star::lang::XSingleComponentFactory or factory instance (::com::sun::star::lang::XSingleComponentFactory or
::com::sun::star::lang::XSingleComponentFactory) ::com::sun::star::lang::XSingleComponentFactory)
@ -57,7 +58,8 @@ SAL_CALL loadSharedLibComponentFactory(
::rtl::OUString const & rLibName, ::rtl::OUString const & rPath, ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath,
::rtl::OUString const & rImplName, ::rtl::OUString const & rImplName,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey ) ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey,
::rtl::OUString const & rPrefix = ::rtl::OUString() )
SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) ); SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) );
/** Invokes component_writeInfo() function of specified component library. You can give either /** Invokes component_writeInfo() function of specified component library. You can give either

View File

@ -31,9 +31,11 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/component.hxx> #include <cppuhelper/component.hxx>
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <cppuhelper/shlib.hxx>
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/typeprovider.hxx>
#include <rtl/instance.hxx> #include <rtl/instance.hxx>
#include <rtl/unload.h> #include <rtl/unload.h>
@ -832,6 +834,7 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
OUString aActivatorUrl; OUString aActivatorUrl;
OUString aActivatorName; OUString aActivatorName;
OUString aLocation; OUString aLocation;
OUString aPrefix;
Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey( Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey(
OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) ); OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) );
@ -847,6 +850,15 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) ); OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) );
if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII ) if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
aLocation = xLocationKey->getAsciiValue(); aLocation = xLocationKey->getAsciiValue();
Reference<XRegistryKey > xPrefixKey = xImplementationKey->openKey(
OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/PREFIX") ) );
if( xPrefixKey.is() && xPrefixKey->getValueType() == RegistryValueType_ASCII )
{
aPrefix = xPrefixKey->getAsciiValue();
if (aPrefix.getLength() != 0)
aPrefix = aPrefix + OUSTR("_");
}
} }
else else
{ {
@ -881,6 +893,17 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
Reference<XInterface > x = xSMgr->createInstance( aActivatorName ); Reference<XInterface > x = xSMgr->createInstance( aActivatorName );
Reference<XImplementationLoader > xLoader( x, UNO_QUERY ); Reference<XImplementationLoader > xLoader( x, UNO_QUERY );
Reference<XInterface > xMF; Reference<XInterface > xMF;
if( aActivatorName == OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") ) )
{
try
{
return loadSharedLibComponentFactory( bootstrap_expandUri( aLocation ), OUString(), aImplementationName, xSMgr, xImplementationKey, aPrefix );
}
catch ( IllegalArgumentException & e )
{
throw RuntimeException( e.Message, e.Context );
}
}
if (xLoader.is()) if (xLoader.is())
{ {
xFactory = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey ); xFactory = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey );

View File

@ -158,6 +158,7 @@ _ZN4cppu28createSingleComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInt
_ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE; _ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE;
_ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE; _ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE;
_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; _ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE;
_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEES3_;
_ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE; _ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE;
_ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; _ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE;
_ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; _ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE;

View File

@ -158,6 +158,7 @@ _ZN4cppu28createSingleComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInt
_ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE; _ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE;
_ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE; _ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE;
_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; _ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE;
_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEES3_;
_ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE; _ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE;
_ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; _ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE;
_ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; _ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE;

View File

@ -275,13 +275,14 @@ static OUString getLibEnv(OUString const & aModulePath,
uno::Environment * pEnv, uno::Environment * pEnv,
OUString * pSourceEnv_name, OUString * pSourceEnv_name,
uno::Environment const & cTargetEnv, uno::Environment const & cTargetEnv,
OUString const & cImplName = OUString()) OUString const & cImplName = OUString(),
OUString const & rPrefix = OUString())
{ {
OUString aExcMsg; OUString aExcMsg;
sal_Char const * pEnvTypeName = NULL; sal_Char const * pEnvTypeName = NULL;
OUString aGetEnvNameExt = OUSTR(COMPONENT_GETENVEXT); OUString aGetEnvNameExt = rPrefix + OUSTR(COMPONENT_GETENVEXT);
component_getImplementationEnvironmentExtFunc pGetImplEnvExt = component_getImplementationEnvironmentExtFunc pGetImplEnvExt =
(component_getImplementationEnvironmentExtFunc)osl_getFunctionSymbol(lib, aGetEnvNameExt.pData); (component_getImplementationEnvironmentExtFunc)osl_getFunctionSymbol(lib, aGetEnvNameExt.pData);
@ -292,7 +293,7 @@ static OUString getLibEnv(OUString const & aModulePath,
} }
else else
{ {
OUString aGetEnvName = OUSTR(COMPONENT_GETENV); OUString aGetEnvName = rPrefix + OUSTR(COMPONENT_GETENV);
component_getImplementationEnvironmentFunc pGetImplEnv = component_getImplementationEnvironmentFunc pGetImplEnv =
(component_getImplementationEnvironmentFunc)osl_getFunctionSymbol( (component_getImplementationEnvironmentFunc)osl_getFunctionSymbol(
lib, aGetEnvName.pData ); lib, aGetEnvName.pData );
@ -348,7 +349,8 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
OUString const & rLibName, OUString const & rPath, OUString const & rLibName, OUString const & rPath,
OUString const & rImplName, OUString const & rImplName,
Reference< lang::XMultiServiceFactory > const & xMgr, Reference< lang::XMultiServiceFactory > const & xMgr,
Reference< registry::XRegistryKey > const & xKey ) Reference< registry::XRegistryKey > const & xKey,
OUString const & rPrefix )
SAL_THROW( (loader::CannotActivateFactoryException) ) SAL_THROW( (loader::CannotActivateFactoryException) )
{ {
OUString aModulePath( makeComponentPath( rLibName, rPath ) ); OUString aModulePath( makeComponentPath( rLibName, rPath ) );
@ -376,10 +378,10 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
OUString aEnvTypeName; OUString aEnvTypeName;
OUString aExcMsg = getLibEnv(aModulePath, lib, &env, &aEnvTypeName, currentEnv, rImplName); OUString aExcMsg = getLibEnv(aModulePath, lib, &env, &aEnvTypeName, currentEnv, rImplName, rPrefix);
if (!aExcMsg.getLength()) if (!aExcMsg.getLength())
{ {
OUString aGetFactoryName = OUSTR(COMPONENT_GETFACTORY); OUString aGetFactoryName = rPrefix + OUSTR(COMPONENT_GETFACTORY);
oslGenericFunction pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData ); oslGenericFunction pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData );
if (pSym != 0) if (pSym != 0)
{ {