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
This commit is contained in:
Michael Meeks 2011-06-24 12:24:49 +01:00
parent f1be5778f8
commit babdd43fce
7 changed files with 59 additions and 7 deletions

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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"/>

View file

@ -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("_");
}
}

View file

@ -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,

View file

@ -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 );
}