diff options
author | Matus Kukan <matus.kukan@gmail.com> | 2011-06-16 17:01:51 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-06-24 12:15:50 +0100 |
commit | 286619e815b022e1271602785f2379e4e79d7ec3 (patch) | |
tree | fd51b1c96b1ace8201ca0b7e3baf14a3a42924df | |
parent | 841d8d9066128a75a14a0a5869621ec26a09c14e (diff) |
Allows using prefix information about component
-rw-r--r-- | cppuhelper/inc/cppuhelper/shlib.hxx | 4 | ||||
-rw-r--r-- | cppuhelper/source/factory.cxx | 23 | ||||
-rw-r--r-- | cppuhelper/source/gcc3.map | 1 | ||||
-rw-r--r-- | cppuhelper/source/gcc3os2.map | 1 | ||||
-rw-r--r-- | cppuhelper/source/shlib.cxx | 14 |
5 files changed, 36 insertions, 7 deletions
diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx index a092ce34a..002ce94e0 100644 --- a/cppuhelper/inc/cppuhelper/shlib.hxx +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -48,6 +48,7 @@ namespace cppu @param rImplName implementation to be retrieved from the library @param xMgr service manager to be provided to the component @param xKey registry key to be provided to the component + @param rPrefix optional component prefix @return factory instance (::com::sun::star::lang::XSingleComponentFactory or ::com::sun::star::lang::XSingleComponentFactory) @@ -57,7 +58,8 @@ SAL_CALL loadSharedLibComponentFactory( ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath, ::rtl::OUString const & rImplName, ::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) ); /** Invokes component_writeInfo() function of specified component library. You can give either diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 63d22c877..434422279 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -31,9 +31,11 @@ #include <osl/diagnose.h> #include <osl/mutex.hxx> #include <cppuhelper/weak.hxx> +#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/component.hxx> #include <cppuhelper/factory.hxx> #include <cppuhelper/implbase3.hxx> +#include <cppuhelper/shlib.hxx> #include <cppuhelper/typeprovider.hxx> #include <rtl/instance.hxx> #include <rtl/unload.h> @@ -832,6 +834,7 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory() OUString aActivatorUrl; OUString aActivatorName; OUString aLocation; + OUString aPrefix; Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey( OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) ); @@ -847,6 +850,15 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory() OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) ); if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII ) 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 { @@ -881,6 +893,17 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory() Reference<XInterface > x = xSMgr->createInstance( aActivatorName ); Reference<XImplementationLoader > xLoader( x, UNO_QUERY ); 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()) { xFactory = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey ); diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 0aee99691..47983baa3 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -158,6 +158,7 @@ _ZN4cppu28createSingleComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInt _ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE; _ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE; _ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; +_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEES3_; _ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE; _ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; _ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; diff --git a/cppuhelper/source/gcc3os2.map b/cppuhelper/source/gcc3os2.map index 2c3bd2d64..dba4c89a3 100644 --- a/cppuhelper/source/gcc3os2.map +++ b/cppuhelper/source/gcc3os2.map @@ -158,6 +158,7 @@ _ZN4cppu28createSingleComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInt _ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE; _ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE; _ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; +_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEES3_; _ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE; _ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; _ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx index 358aac184..6f83bac47 100644 --- a/cppuhelper/source/shlib.cxx +++ b/cppuhelper/source/shlib.cxx @@ -275,13 +275,14 @@ static OUString getLibEnv(OUString const & aModulePath, uno::Environment * pEnv, OUString * pSourceEnv_name, uno::Environment const & cTargetEnv, - OUString const & cImplName = OUString()) + OUString const & cImplName = OUString(), + OUString const & rPrefix = OUString()) { OUString aExcMsg; sal_Char const * pEnvTypeName = NULL; - OUString aGetEnvNameExt = OUSTR(COMPONENT_GETENVEXT); + OUString aGetEnvNameExt = rPrefix + OUSTR(COMPONENT_GETENVEXT); component_getImplementationEnvironmentExtFunc pGetImplEnvExt = (component_getImplementationEnvironmentExtFunc)osl_getFunctionSymbol(lib, aGetEnvNameExt.pData); @@ -292,7 +293,7 @@ static OUString getLibEnv(OUString const & aModulePath, } else { - OUString aGetEnvName = OUSTR(COMPONENT_GETENV); + OUString aGetEnvName = rPrefix + OUSTR(COMPONENT_GETENV); component_getImplementationEnvironmentFunc pGetImplEnv = (component_getImplementationEnvironmentFunc)osl_getFunctionSymbol( lib, aGetEnvName.pData ); @@ -348,7 +349,8 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( OUString const & rLibName, OUString const & rPath, OUString const & rImplName, Reference< lang::XMultiServiceFactory > const & xMgr, - Reference< registry::XRegistryKey > const & xKey ) + Reference< registry::XRegistryKey > const & xKey, + OUString const & rPrefix ) SAL_THROW( (loader::CannotActivateFactoryException) ) { OUString aModulePath( makeComponentPath( rLibName, rPath ) ); @@ -376,10 +378,10 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( OUString aEnvTypeName; - OUString aExcMsg = getLibEnv(aModulePath, lib, &env, &aEnvTypeName, currentEnv, rImplName); + OUString aExcMsg = getLibEnv(aModulePath, lib, &env, &aEnvTypeName, currentEnv, rImplName, rPrefix); if (!aExcMsg.getLength()) { - OUString aGetFactoryName = OUSTR(COMPONENT_GETFACTORY); + OUString aGetFactoryName = rPrefix + OUSTR(COMPONENT_GETFACTORY); oslGenericFunction pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData ); if (pSym != 0) { |