diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-06-24 12:24:49 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-06-24 14:23:25 +0100 |
commit | b5b064c930426e706dc30486ee40213995da7989 (patch) | |
tree | 7e39413577db7919baa6a1b6cc0f88a2073f008a | |
parent | 286619e815b022e1271602785f2379e4e79d7ec3 (diff) |
re-work prefix handling and undo cppuhelper ABI change, add unit test
use a separate prefix enabled method instead of changing the ABI of cppuhelper
also - lookup the prefix in the dllcomponentloader in case we are called this way
also - add a unit test for the prefix change
-rw-r--r-- | cppuhelper/inc/cppuhelper/shlib.hxx | 28 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx | 6 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/makefile.mk | 1 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component | 2 | ||||
-rw-r--r-- | cppuhelper/source/factory.cxx | 2 | ||||
-rw-r--r-- | cppuhelper/source/shlib.cxx | 11 | ||||
-rw-r--r-- | stoc/source/loader/dllcomponentloader.cxx | 20 |
7 files changed, 61 insertions, 9 deletions
diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx index 002ce94e0..ebbc1e1d9 100644 --- a/cppuhelper/inc/cppuhelper/shlib.hxx +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -42,7 +42,31 @@ namespace cppu (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific directory. The resulting path of the library will be checked against environment variable CPLD_ACCESSPATH if set. - + + @param rLibName name of the library + @param rPath optional path + @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 + @return + factory instance (::com::sun::star::lang::XSingleComponentFactory or + ::com::sun::star::lang::XSingleComponentFactory) +*/ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +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 ) + SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) ); + +/** Loads a shared library component and gets the factory out of it. You can give either a + fully qualified libname or single lib name. The libname need not be pre/postfixed + (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific + directory. The resulting path of the library will be checked against environment variable + CPLD_ACCESSPATH if set. An optional 'prefix' parameter is used to determine the symbol + name of the entry point in the library. + @param rLibName name of the library @param rPath optional path @param rImplName implementation to be retrieved from the library @@ -59,7 +83,7 @@ SAL_CALL loadSharedLibComponentFactory( ::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, - ::rtl::OUString const & rPrefix = ::rtl::OUString() ) + ::rtl::OUString const & rPrefix ) SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) ); /** Invokes component_writeInfo() function of specified component library. You can give either diff --git a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx index c1f3af984..100c5300e 100644 --- a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx @@ -411,19 +411,19 @@ css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() { cppu::ImplementationEntry entries[] = { { &create, &getImplementationName, &getSupportedServiceNames, - &cppu::createSingleComponentFactory, 0, 0 }, + &cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; } -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL mixin_component_getFactory( char const * implName, void * serviceManager, void * registryKey) { return cppu::component_getFactoryHelper( implName, serviceManager, registryKey, entries); } -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL mixin_component_getImplementationEnvironment( char const ** envTypeName, uno_Environment **) { *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk index be4cfc380..384e2b047 100644 --- a/cppuhelper/qa/propertysetmixin/makefile.mk +++ b/cppuhelper/qa/propertysetmixin/makefile.mk @@ -66,7 +66,6 @@ DEF1NAME = $(SHL1TARGET) SHL2TARGET = $(TARGET).uno SHL2OBJS = $(SLO)/comp_propertysetmixin.obj -SHL2VERSIONMAP = $(SOLARENV)/src/component.map SHL2STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) SHL2IMPLIB = i$(SHL2TARGET) SH21RPATH = NONE diff --git a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component index a654e0758..1ae646e98 100644 --- a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component +++ b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component @@ -26,7 +26,7 @@ * **********************************************************************--> -<component loader="com.sun.star.loader.SharedLibrary" +<component loader="com.sun.star.loader.SharedLibrary" prefix="mixin" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="test.cppuhelper.propertysetmixin.comp.CppSupplier"> <service name="test.cppuhelper.propertysetmixin.CppSupplier"/> diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 434422279..f86fd3263 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -856,7 +856,7 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory() if( xPrefixKey.is() && xPrefixKey->getValueType() == RegistryValueType_ASCII ) { aPrefix = xPrefixKey->getAsciiValue(); - if (aPrefix.getLength() != 0) + if( aPrefix.getLength() != 0 ) aPrefix = aPrefix + OUSTR("_"); } } diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx index 6f83bac47..1fb136acf 100644 --- a/cppuhelper/source/shlib.cxx +++ b/cppuhelper/source/shlib.cxx @@ -345,6 +345,17 @@ extern "C" {static void s_getFactory(va_list * pParam) *ppSSF = pSym(pImplName->getStr(), pSMgr, pKey); }} +/* For backwards compatibility */ +Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( + OUString const & rLibName, OUString const & rPath, + OUString const & rImplName, + Reference< lang::XMultiServiceFactory > const & xMgr, + Reference< registry::XRegistryKey > const & xKey ) + SAL_THROW( (loader::CannotActivateFactoryException) ) +{ + return loadSharedLibComponentFactory( rLibName, rPath, rImplName, xMgr, xKey, rtl::OUString() ); +} + Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( OUString const & rLibName, OUString const & rPath, OUString const & rImplName, diff --git a/stoc/source/loader/dllcomponentloader.cxx b/stoc/source/loader/dllcomponentloader.cxx index 78aca34d3..9c27a1f1b 100644 --- a/stoc/source/loader/dllcomponentloader.cxx +++ b/stoc/source/loader/dllcomponentloader.cxx @@ -202,8 +202,26 @@ Reference<XInterface> SAL_CALL DllComponentLoader::activate( throw(CannotActivateFactoryException, RuntimeException) { + rtl::OUString aPrefix; + if( xKey.is() ) + { + Reference<XRegistryKey > xActivatorKey = xKey->openKey( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) ); + if (xActivatorKey.is() && xActivatorKey->getValueType() == RegistryValueType_ASCII ) + { + Reference<XRegistryKey > xPrefixKey = xActivatorKey->openKey( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/PREFIX") ) ); + if( xPrefixKey.is() && xPrefixKey->getValueType() == RegistryValueType_ASCII ) + { + aPrefix = xPrefixKey->getAsciiValue(); + if( aPrefix.getLength() != 0 ) + aPrefix = aPrefix + OUSTR("_"); + } + } + } + return loadSharedLibComponentFactory( - expand_url( rLibName ), OUString(), rImplName, m_xSMgr, xKey ); + expand_url( rLibName ), OUString(), rImplName, m_xSMgr, xKey, aPrefix ); } |