[Libreoffice-commits] .: 2 commits - cppuhelper/inc cppuhelper/qa cppuhelper/source stoc/source
Michael Meeks
michael at kemper.freedesktop.org
Fri Jun 24 06:24:45 PDT 2011
cppuhelper/inc/cppuhelper/shlib.hxx | 28 +++++++++-
cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx | 6 +-
cppuhelper/qa/propertysetmixin/makefile.mk | 1
cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component | 2
cppuhelper/source/factory.cxx | 23 ++++++++
cppuhelper/source/gcc3.map | 1
cppuhelper/source/gcc3os2.map | 1
cppuhelper/source/shlib.cxx | 23 ++++++--
stoc/source/loader/dllcomponentloader.cxx | 20 ++++++-
9 files changed, 93 insertions(+), 12 deletions(-)
New commits:
commit b5b064c930426e706dc30486ee40213995da7989
Author: Michael Meeks <michael.meeks at novell.com>
Date: Fri Jun 24 12:24:49 2011 +0100
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
diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx
index 002ce94..ebbc1e1 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 c1f3af9..100c530 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 be4cfc3..384e2b0 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 a654e07..1ae646e 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 4344222..f86fd32 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 6f83bac..1fb136a 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 78aca34..9c27a1f 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 );
}
commit 286619e815b022e1271602785f2379e4e79d7ec3
Author: Matus Kukan <matus.kukan at gmail.com>
Date: Thu Jun 16 17:01:51 2011 +0200
Allows using prefix information about component
diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx
index a092ce3..002ce94 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 63d22c8..4344222 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 0aee996..47983ba 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 2c3bd2d..dba4c89 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 358aac1..6f83bac 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)
{
More information about the Libreoffice-commits
mailing list