From babdd43fcee0963f80df3ed6574e8f70543827e2 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 24 Jun 2011 12:24:49 +0100 Subject: [PATCH] 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 --- cppuhelper/inc/cppuhelper/shlib.hxx | 26 ++++++++++++++++++- .../comp_propertysetmixin.cxx | 4 +-- cppuhelper/qa/propertysetmixin/makefile.mk | 1 - .../qa_propertysetmixin.cpp.component | 2 +- cppuhelper/source/factory.cxx | 2 +- cppuhelper/source/shlib.cxx | 11 ++++++++ stoc/source/loader/dllcomponentloader.cxx | 20 +++++++++++++- 7 files changed, 59 insertions(+), 7 deletions(-) diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx index 582993f857d5..ed7f74107cae 100644 --- a/cppuhelper/inc/cppuhelper/shlib.hxx +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -43,6 +43,30 @@ namespace cppu 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 2fd0d494c99d..c93d24b39e79 100644 --- a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx @@ -416,14 +416,14 @@ cppu::ImplementationEntry entries[] = { } -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 be4cfc380947..384e2b047883 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 a654e07581a3..1ae646e98017 100644 --- a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component +++ b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component @@ -26,7 +26,7 @@ * **********************************************************************--> - diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index a87d39ad91f5..bccc91db36eb 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 1127cc3f0a4a..62d772637dfd 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 86d96a76ce3a..4fd75a53060e 100644 --- a/stoc/source/loader/dllcomponentloader.cxx +++ b/stoc/source/loader/dllcomponentloader.cxx @@ -202,8 +202,26 @@ Reference SAL_CALL DllComponentLoader::activate( throw(CannotActivateFactoryException, RuntimeException) { + rtl::OUString aPrefix; + if( xKey.is() ) + { + Reference xActivatorKey = xKey->openKey( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) ); + if (xActivatorKey.is() && xActivatorKey->getValueType() == RegistryValueType_ASCII ) + { + Reference 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 ); }