diff options
author | Tor Lillqvist <tml@iki.fi> | 2012-03-20 23:18:55 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2012-03-21 00:00:11 +0200 |
commit | 25d114eec4d451acdda1ddff4c8ed9d47ba6275f (patch) | |
tree | ca69e10288f4d1752ba91bc2b5dc457c8d5633ee /ucbhelper | |
parent | 9423429a70ecadb09108a0c90db90db68e49c6f6 (diff) |
Initial experiments with static linking of (some) components / services
Start with the first service needed when running sc's filters_test:
the UniversalContentBroker. It might not be typical as ucb uses the
deprecated XSingleServiceFactory.
This commit is not at all a complete solution, far from it, just an
initial hack. Naturally once I come up with some generic enough way to
do the static linking the necessary macros etc will be added to some
general header.
The macro XSERVICEINFO_IMPL_1 (local to ucbhelper and ucb) is amended
so that it in the disable-dynamic-linking case also emits a function
whose assembler name equal contains the service name. This function
returns the XSingleServiceFactory for the service. Where the service
is instantiated we link directly to that function.
But probably this will be reworked a couple of times... Maybe it would
be better to simply have the service name specific entry point be a
pointer to the component's component_getFactory() function? Those all
have the same prototype.
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/inc/ucbhelper/macros.hxx | 39 | ||||
-rw-r--r-- | ucbhelper/source/client/contentbroker.cxx | 34 |
2 files changed, 57 insertions, 16 deletions
diff --git a/ucbhelper/inc/ucbhelper/macros.hxx b/ucbhelper/inc/ucbhelper/macros.hxx index 302be2132f05..445de8a05e26 100644 --- a/ucbhelper/inc/ucbhelper/macros.hxx +++ b/ucbhelper/inc/ucbhelper/macros.hxx @@ -732,19 +732,40 @@ XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ com::sun::star::uno::Sequence< rtl::OUString > \ Class::getSupportedServiceNames_Static() -// 1 service name -#define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \ -XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ -XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ +#ifdef DISABLE_DYNLOADING + +#define STATICALLY_LINKED_SERVICE( Class, ImplName, Service, Num ) \ +extern com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service##Num( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) \ + __asm("SSF:" Service); \ \ -com::sun::star::uno::Sequence< rtl::OUString > \ -Class::getSupportedServiceNames_Static() \ +com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service##Num( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) \ { \ - com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 ); \ - aSNS.getArray()[ 0 ] = Service1; \ - return aSNS; \ + com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory( Class::createServiceFactory( rSMgr ) ); \ + xFactory->acquire(); \ + return xFactory; \ } +#else + +#define STATICALLY_LINKED_SERVICE( Class, ImplName, Service, Num ) // empty + +#endif + +// 1 service name +#define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \ +XSERVICEINFO_COMMOM_IMPL( Class, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ImplName )) ) \ +XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ + \ +com::sun::star::uno::Sequence< rtl::OUString > \ +Class::getSupportedServiceNames_Static() \ +{ \ + com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 ); \ + aSNS.getArray()[ 0 ] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( Service1 )); \ + return aSNS; \ +} \ + \ +STATICALLY_LINKED_SERVICE( Class, ImplName, Service1, 1 ) + #endif /* !_UCBHELPER_MACROS_HXX */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx index eb18dc75edb6..0d865478bd8a 100644 --- a/ucbhelper/source/client/contentbroker.cxx +++ b/ucbhelper/source/client/contentbroker.cxx @@ -34,6 +34,7 @@ *************************************************************************/ #include <osl/diagnose.h> #include <osl/mutex.hxx> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> @@ -42,6 +43,30 @@ #include <com/sun/star/ucb/XCommandProcessor.hpp> #include <ucbhelper/contentbroker.hxx> +#ifdef DISABLE_DYNLOADING + +#define MSF_CREATEINSTANCE(Msf, Service) \ +({ \ + extern com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) __asm("SSF:" Service); \ + com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory( service( Msf ) ); \ + xFactory->createInstance(); \ +}) + +#define MSF_CREATEINSTANCE_WITHARGUMENTS(Msf, Service, Args) \ +({ \ + extern com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) __asm("SSF:" Service); \ + com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory( service( Msf ) ); \ + xFactory->createInstanceWithArguments( Args ); \ +}) + +#else + +#define MSF_CREATEINSTANCE(Msf, Service) Msf->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( Service )) ) + +#define MSF_CREATEINSTANCE_WITHARGUMENTS(Msf, Service, Args) Msf->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( Service )), Args ) + +#endif + using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::uno; @@ -248,9 +273,7 @@ bool ContentBroker_Impl::initialize() { try { - xIfc = m_xSMgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.ucb.UniversalContentBroker" )) ); + xIfc = MSF_CREATEINSTANCE( m_xSMgr, "com.sun.star.ucb.UniversalContentBroker" ); } catch ( Exception const & ) { @@ -282,10 +305,7 @@ bool ContentBroker_Impl::initialize() { try { - xIfc = m_xSMgr->createInstanceWithArguments( - OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.ucb.UniversalContentBroker" )), - m_aArguments ); + xIfc = MSF_CREATEINSTANCE_WITHARGUMENTS( m_xSMgr, "com.sun.star.ucb.UniversalContentBroker", m_aArguments ); } catch ( Exception const & ) { |