diff options
Diffstat (limited to 'remotebridges')
-rw-r--r-- | remotebridges/examples/exports.dxp | 2 | ||||
-rw-r--r-- | remotebridges/examples/makefile.mk | 61 | ||||
-rw-r--r-- | remotebridges/examples/officeclient.cxx | 330 | ||||
-rw-r--r-- | remotebridges/prj/build.lst | 2 | ||||
-rw-r--r-- | remotebridges/prj/d.lst | 4 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/makefile.mk | 72 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/unourl_resolver.cxx | 225 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/uuresolver.component | 34 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/uuresolver.xml | 38 |
9 files changed, 768 insertions, 0 deletions
diff --git a/remotebridges/examples/exports.dxp b/remotebridges/examples/exports.dxp new file mode 100644 index 000000000000..51703a04666a --- /dev/null +++ b/remotebridges/examples/exports.dxp @@ -0,0 +1,2 @@ +component_writeInfo +component_getFactory diff --git a/remotebridges/examples/makefile.mk b/remotebridges/examples/makefile.mk new file mode 100644 index 000000000000..ec268788b3fe --- /dev/null +++ b/remotebridges/examples/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=.. + +PRJNAME=remotebridges +TARGET=officeclientsample +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +SLOFILES = $(SLO)$/officeclient.obj + +SHL1TARGET= officeclientsample + +SHL1STDLIBS= \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/$(SHL1TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/remotebridges/examples/officeclient.cxx b/remotebridges/examples/officeclient.cxx new file mode 100644 index 000000000000..40c902332406 --- /dev/null +++ b/remotebridges/examples/officeclient.cxx @@ -0,0 +1,330 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include <stdio.h> +#include <osl/mutex.hxx> +#include <cppuhelper/factory.hxx> + +#include <cppuhelper/servicefactory.hxx> + +#include <com/sun/star/uno/XNamingService.hpp> + +#include <com/sun/star/registry/XImplementationRegistration.hpp> + +#include <com/sun/star/connection/XConnector.hpp> + +#include <com/sun/star/bridge/XUnoUrlResolver.hpp> + +#include <com/sun/star/lang/XMain.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <com/sun/star/frame/XComponentLoader.hpp> + +#include <com/sun/star/text/XTextDocument.hpp> + +#include <cppuhelper/implbase1.hxx> + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; +using namespace ::com::sun::star::connection; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::bridge; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::frame; + + + +namespace remotebridges_officeclient { + +class OfficeClientMain : public WeakImplHelper1< XMain > +{ +public: + OfficeClientMain( const Reference< XMultiServiceFactory > &r ) : + m_xSMgr( r ) + {} +public: // Methods + + + virtual sal_Int32 SAL_CALL run( const Sequence< OUString >& aArguments ) + throw(RuntimeException); + + +private: // helper methods + void testWriter( const Reference < XComponent > & rComponent ); + void registerServices(); + Reference< XMultiServiceFactory > m_xSMgr; +}; + +void OfficeClientMain::testWriter( const Reference< XComponent > & rComponent ) +{ + printf( "pasting some text into the writer document\n" ); + + Reference< XTextDocument > rTextDoc( rComponent , UNO_QUERY ); + Reference< XText > rText = rTextDoc->getText(); + Reference< XTextCursor > rCursor = rText->createTextCursor(); + Reference< XTextRange > rRange ( rCursor , UNO_QUERY ); + + rText->insertString( rRange, OUString(RTL_CONSTASCII_USTRINGPARAM("This text has been posted by the officeclient component")), sal_False ); +} + +/******************** + * does necessary service registration ( this could be done also by a setup tool ) + *********************/ +void OfficeClientMain::registerServices( ) +{ + // register services. + // Note : this needs to be done only once and is in general done by the setup + Reference < XImplementationRegistration > rImplementationRegistration( + + m_xSMgr->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration"))), + UNO_QUERY ); + + if( ! rImplementationRegistration.is() ) + { + printf( "Couldn't create registration component\n" ); + exit(1); + } + + OUString aSharedLibrary[4]; + aSharedLibrary[0] = + OUString(RTL_CONSTASCII_USTRINGPARAM( "connector.uno" SAL_DLLEXTENSION )); + aSharedLibrary[1] = + OUString(RTL_CONSTASCII_USTRINGPARAM( "remotebridge.uno" SAL_DLLEXTENSION )); + aSharedLibrary[2] = + OUString(RTL_CONSTASCII_USTRINGPARAM( "bridgefac.uno" SAL_DLLEXTENSION )); + aSharedLibrary[3] = + OUString(RTL_CONSTASCII_USTRINGPARAM( "uuresolver.uno" SAL_DLLEXTENSION )); + + sal_Int32 i; + for( i = 0 ; i < 4 ; i ++ ) + { + + // build the system specific library name + OUString aDllName = aSharedLibrary[i]; + + try + { + // register the needed services in the servicemanager + rImplementationRegistration->registerImplementation( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")), + aDllName, + Reference< XSimpleRegistry > () ); + } + catch( Exception & ) + { + printf( "couldn't register dll %s\n" , + OUStringToOString( aDllName, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } +} + +sal_Int32 OfficeClientMain::run( const Sequence< OUString > & aArguments ) throw ( RuntimeException ) +{ + printf( "Connecting ....\n" ); + + if( aArguments.getLength() == 1 ) + { + try { + registerServices(); + Reference < XInterface > r = + m_xSMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.UnoUrlResolver")) ); + Reference < XUnoUrlResolver > rResolver( r , UNO_QUERY ); + r = rResolver->resolve( aArguments.getConstArray()[0] ); + + Reference< XNamingService > rNamingService( r, UNO_QUERY ); + if( rNamingService.is() ) + { + printf( "got the remote NamingService\n" ); + + r = rNamingService->getRegisteredObject(OUString(RTL_CONSTASCII_USTRINGPARAM("StarOffice.ServiceManager"))); + + Reference< XMultiServiceFactory > rRemoteSMgr( r , UNO_QUERY ); + + Reference < XComponentLoader > rLoader( + rRemoteSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ))), + UNO_QUERY ); + + if( rLoader.is() ) + { + + sal_Char *urls[] = { + "private:factory/swriter", + "private:factory/sdraw", + "private:factory/simpress", + "private:factory/scalc" + }; + + sal_Char *docu[]= { + "a new writer document ...\n", + "a new draw document ...\n", + "a new schedule document ...\n" , + "a new calc document ...\n" + }; + sal_Int32 i; + for( i = 0 ; i < 4 ; i ++ ) + { + printf( "press any key to open %s\n" , docu[i] ); + getchar(); + + Reference< XComponent > rComponent = + rLoader->loadComponentFromURL( + OUString::createFromAscii( urls[i] ) , + OUString( RTL_CONSTASCII_USTRINGPARAM("_blank")), + 0 , + Sequence < ::com::sun::star::beans::PropertyValue >() ); + + if( 0 == i ) + { + testWriter( rComponent ); + } + printf( "press any key to close the document\n" ); + getchar(); + rComponent->dispose(); + } + } + } + + } + catch( ConnectionSetupException &e ) + { + OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); + printf( "%s\n", o.pData->buffer ); + printf( "couldn't access local resource ( possible security resons )\n" ); + } + catch( NoConnectException &e ) + { + OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); + printf( "%s\n", o.pData->buffer ); + printf( "no server listening on the resource\n" ); + } + catch( IllegalArgumentException &e ) + { + OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); + printf( "%s\n", o.pData->buffer ); + printf( "uno url invalid\n" ); + } + catch( RuntimeException & e ) + { + OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); + printf( "%s\n", o.pData->buffer ); + printf( "a remote call was aborted\n" ); + } + } + else + { + printf( "usage: (uno officeclient-component --) uno-url\n" + "e.g.: uno:socket,host=localhost,port=2002;urp;StarOffice.NamingService\n" ); + return 1; + } + return 0; +} + +Reference< XInterface > SAL_CALL CreateInstance( const Reference< XMultiServiceFactory > &r) +{ + return Reference< XInterface > ( ( OWeakObject * ) new OfficeClientMain(r) ); +} + +Sequence< OUString > getSupportedServiceNames() +{ + static Sequence < OUString > *pNames = 0; + if( ! pNames ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( !pNames ) + { + static Sequence< OUString > seqNames(2); + seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.example.OfficeClientExample")); + pNames = &seqNames; + } + } + return *pNames; +} + +} + +using namespace remotebridges_officeclient; +#define IMPLEMENTATION_NAME "com.sun.star.comp.remotebridges.example.OfficeClientSample" + + +extern "C" +{ +//================================================================================================== +sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey ) +{ + if (pRegistryKey) + { + try + { + Reference< XRegistryKey > xNewKey( + reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( + OUString(RTL_CONSTASCII_USTRINGPARAM( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" )) ) ); + + const Sequence< OUString > & rSNL = getSupportedServiceNames(); + const OUString * pArray = rSNL.getConstArray(); + for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) + xNewKey->createKey( pArray[nPos] ); + + return sal_True; + } + catch (InvalidRegistryException &) + { + OSL_FAIL( "### InvalidRegistryException!" ); + } + } + return sal_False; +} +//================================================================================================== +SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + void * pRet = 0; + + if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + CreateInstance, getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/prj/build.lst b/remotebridges/prj/build.lst new file mode 100644 index 000000000000..ae454aa89075 --- /dev/null +++ b/remotebridges/prj/build.lst @@ -0,0 +1,2 @@ +rb remotebridges : LIBXSLT:libxslt cppu cppuhelper offapi DESKTOP:rdbmaker sal NULL +rb remotebridges\source\unourl_resolver nmake - all rb_urlresolv NULL diff --git a/remotebridges/prj/d.lst b/remotebridges/prj/d.lst new file mode 100644 index 000000000000..8f9c063f196d --- /dev/null +++ b/remotebridges/prj/d.lst @@ -0,0 +1,4 @@ +..\%__SRC%\bin\uuresolver.uno.dll %_DEST%\bin\uuresolver.uno.dll +..\%__SRC%\lib\uuresolver.uno.dylib %_DEST%\lib\uuresolver.uno.dylib +..\%__SRC%\lib\uuresolver.uno.so %_DEST%\lib\uuresolver.uno.so +..\%__SRC%\misc\uuresolver.component %_DEST%\xml\uuresolver.component diff --git a/remotebridges/source/unourl_resolver/makefile.mk b/remotebridges/source/unourl_resolver/makefile.mk new file mode 100644 index 000000000000..edf5aa72c128 --- /dev/null +++ b/remotebridges/source/unourl_resolver/makefile.mk @@ -0,0 +1,72 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=remotebridges +TARGET = uuresolver.uno +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST = uuresolver + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" +DLLPRE = + +# ------------------------------------------------------------------ + +SLOFILES= \ + $(SLO)$/unourl_resolver.obj + +SHL1TARGET= $(TARGET) +SHL1VERSIONMAP = $(SOLARENV)/src/unloadablecomponent.map + +SHL1STDLIBS= \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def +SHL1RPATH= URELIB + +DEF1NAME= $(SHL1TARGET) +.ENDIF # L10N_framework + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +ALLTAR : $(MISC)/uuresolver.component + +$(MISC)/uuresolver.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + uuresolver.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt uuresolver.component diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx new file mode 100644 index 000000000000..459f2fe0efd0 --- /dev/null +++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx @@ -0,0 +1,225 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// #define TRACE(x) OSL_TRACE(x) +#define TRACE(x) + +#include <osl/diagnose.h> +#include <osl/mutex.hxx> +#include <cppuhelper/factory.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implementationentry.hxx> +#include "cppuhelper/unourl.hxx" +#include "rtl/malformeduriexception.hxx" + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/connection/XConnector.hpp> +#include <com/sun/star/bridge/XBridgeFactory.hpp> +#include <com/sun/star/bridge/XUnoUrlResolver.hpp> + +using namespace cppu; +using namespace osl; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::connection; +using namespace com::sun::star::bridge; +using namespace com::sun::star::registry; + +using ::rtl::OUString; + +#define SERVICENAME "com.sun.star.bridge.UnoUrlResolver" +#define IMPLNAME "com.sun.star.comp.bridge.UnoUrlResolver" + +namespace unourl_resolver +{ + rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; +//-------------------------------------------------------------------------------------------------- +Sequence< OUString > resolver_getSupportedServiceNames() +{ + Sequence< OUString > seqNames(1); + seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME)); + return seqNames; +} + +OUString resolver_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME)); +} + +//================================================================================================== +class ResolverImpl : public WeakImplHelper2< XServiceInfo, XUnoUrlResolver > +{ + Reference< XMultiComponentFactory > _xSMgr; + Reference< XComponentContext > _xCtx; + +public: + ResolverImpl( const Reference< XComponentContext > & xSMgr ); + virtual ~ResolverImpl(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XUnoUrlResolver + virtual Reference< XInterface > SAL_CALL resolve( const OUString & rUnoUrl ) + throw (NoConnectException, ConnectionSetupException, RuntimeException); +}; + +//################################################################################################## + +//__________________________________________________________________________________________________ +ResolverImpl::ResolverImpl( const Reference< XComponentContext > & xCtx ) + : _xSMgr( xCtx->getServiceManager() ) + , _xCtx( xCtx ) +{ + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); +} +//__________________________________________________________________________________________________ +ResolverImpl::~ResolverImpl() +{ + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); +} + +// XServiceInfo +//__________________________________________________________________________________________________ +OUString ResolverImpl::getImplementationName() + throw(::com::sun::star::uno::RuntimeException) +{ + return resolver_getImplementationName(); +} +//__________________________________________________________________________________________________ +sal_Bool ResolverImpl::supportsService( const OUString & rServiceName ) + throw(::com::sun::star::uno::RuntimeException) +{ + const Sequence< OUString > & rSNL = getSupportedServiceNames(); + const OUString * pArray = rSNL.getConstArray(); + for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) + { + if (pArray[nPos] == rServiceName) + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +Sequence< OUString > ResolverImpl::getSupportedServiceNames() + throw(::com::sun::star::uno::RuntimeException) +{ + return resolver_getSupportedServiceNames(); +} + +// XUnoUrlResolver +//__________________________________________________________________________________________________ +Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl ) + throw (NoConnectException, ConnectionSetupException, RuntimeException) +{ + OUString aProtocolDescr; + OUString aConnectDescr; + OUString aInstanceName; + try + { + cppu::UnoUrl aUrl(rUnoUrl); + aProtocolDescr = aUrl.getProtocol().getDescriptor(); + aConnectDescr = aUrl.getConnection().getDescriptor(); + aInstanceName = aUrl.getObjectName(); + } + catch (rtl::MalformedUriException & rEx) + { + throw ConnectionSetupException(rEx.getMessage(), 0); + } + + Reference< XConnector > xConnector( + _xSMgr->createInstanceWithContext( + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ), + _xCtx ), + UNO_QUERY ); + + if (! xConnector.is()) + throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no connector!" ) ), Reference< XInterface >() ); + + Reference< XConnection > xConnection( xConnector->connect( aConnectDescr ) ); + + // As soon as singletons are ready, switch to singleton ! + Reference< XBridgeFactory > xBridgeFactory( + _xSMgr->createInstanceWithContext( + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ), + _xCtx ), + UNO_QUERY ); + + if (! xBridgeFactory.is()) + throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no bridge factory!" ) ), Reference< XInterface >() ); + + // bridge + Reference< XBridge > xBridge( xBridgeFactory->createBridge( + OUString(), aProtocolDescr, + xConnection, Reference< XInstanceProvider >() ) ); + + Reference< XInterface > xRet( xBridge->getInstance( aInstanceName ) ); + + return xRet; +} + +//================================================================================================== +static Reference< XInterface > SAL_CALL ResolverImpl_create( const Reference< XComponentContext > & xCtx ) +{ + return Reference< XInterface >( *new ResolverImpl( xCtx ) ); +} + + +} + +using namespace unourl_resolver; + +static struct ImplementationEntry g_entries[] = +{ + { + ResolverImpl_create, resolver_getImplementationName, + resolver_getSupportedServiceNames, createSingleComponentFactory, + &g_moduleCount.modCnt , 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; + +extern "C" +{ +sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) +{ + return g_moduleCount.canUnload( &g_moduleCount , pTime ); +} + +//================================================================================================== +SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/unourl_resolver/uuresolver.component b/remotebridges/source/unourl_resolver/uuresolver.component new file mode 100644 index 000000000000..f9dcd71d8956 --- /dev/null +++ b/remotebridges/source/unourl_resolver/uuresolver.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.bridge.UnoUrlResolver"> + <service name="com.sun.star.bridge.UnoUrlResolver"/> + </implementation> +</component> diff --git a/remotebridges/source/unourl_resolver/uuresolver.xml b/remotebridges/source/unourl_resolver/uuresolver.xml new file mode 100644 index 000000000000..c959d4c7db2e --- /dev/null +++ b/remotebridges/source/unourl_resolver/uuresolver.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> uuresolver.uno </module-name> + <component-description> + <author> Daniel Boelzle </author> + <name> com.sun.star.comp.bridge.UnoUrlResolver </name> + <description> + This component allows + to retrieve an object reference from another process. + </description> + <loader-name> com.sun.star.loader.SharedLibrary </loader-name> + <language> c++ </language> + <status value="final"/> + <supported-service> com.sun.star.bridge.UnoUrlResolver </supported-service> + <service-dependency> ... </service-dependency> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.lang.XSingleComponentFactory </type> + <type> com.sun.star.uno.XComponentContext </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.connection.XConnector </type> + <type> com.sun.star.bridge.XBridgeFactory </type> + <type> com.sun.star.bridge.XUnoUrlResolver </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.uno.XWeak </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper3 </runtime-module-dependency> + <runtime-module-dependency> cppu3 </runtime-module-dependency> + <runtime-module-dependency> sal3 </runtime-module-dependency> +</module-description> |