From 900d60b3cd648be79aaaa84c992edf9953c0c7f9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 13 Sep 2012 13:30:07 +0200 Subject: fdo#46808, Adapt bridge::BridgeFactory UNO service to new style Create a merged XBridgeFactory2 interface for this service to implement. Which is backwards-compatible, but does not require creating a new service. Change-Id: I7309f4d30f0e772bc203c701eb3407b920ffafcc --- desktop/source/offacc/acceptor.cxx | 18 ++++++++---------- desktop/source/offacc/acceptor.hxx | 6 +++--- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 25 ++++++++++--------------- 3 files changed, 21 insertions(+), 28 deletions(-) (limited to 'desktop') diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx index 64a3d3c77541..2fd0da302885 100644 --- a/desktop/source/offacc/acceptor.cxx +++ b/desktop/source/offacc/acceptor.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -44,12 +45,11 @@ extern "C" void workerfunc (void * acc) ((Acceptor*)acc)->run(); } -static Reference getComponentContext( const Reference& rFactory) +static Reference getComponentContext( const Reference& rFactory) { - Reference rContext; + Reference rContext; Reference< XPropertySet > rPropSet( rFactory, UNO_QUERY ); - Any a = rPropSet->getPropertyValue( - ::rtl::OUString( "DefaultContext" ) ); + Any a = rPropSet->getPropertyValue( ::rtl::OUString( "DefaultContext" ) ); a >>= rContext; return rContext; } @@ -65,14 +65,12 @@ Acceptor::Acceptor( const Reference< XMultiServiceFactory >& rFactory ) , m_bDying(false) { m_rSMgr = rFactory; + // get component context + m_rContext = getComponentContext(m_rSMgr); m_rAcceptor = Reference< XAcceptor > (m_rSMgr->createInstance( rtl::OUString("com.sun.star.connection.Acceptor" )), UNO_QUERY ); - m_rBridgeFactory = Reference < XBridgeFactory > (m_rSMgr->createInstance( - rtl::OUString("com.sun.star.bridge.BridgeFactory" )), - UNO_QUERY ); - // get component context - m_rContext = getComponentContext(m_rSMgr); + m_rBridgeFactory = BridgeFactory::create(m_rContext); } @@ -108,7 +106,7 @@ Acceptor::~Acceptor() void SAL_CALL Acceptor::run() { - while ( m_rAcceptor.is() && m_rBridgeFactory.is() ) + while ( m_rAcceptor.is() ) { RTL_LOGFILE_CONTEXT( aLog, "desktop (lo119109) Acceptor::run" ); try diff --git a/desktop/source/offacc/acceptor.hxx b/desktop/source/offacc/acceptor.hxx index e25f4e308d80..0cb2dd3f6472 100644 --- a/desktop/source/offacc/acceptor.hxx +++ b/desktop/source/offacc/acceptor.hxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,9 +66,9 @@ private: Condition m_cEnable; Reference< XMultiServiceFactory > m_rSMgr; - Reference< XInterface > m_rContext; + Reference< XComponentContext > m_rContext; Reference< XAcceptor > m_rAcceptor; - Reference< XBridgeFactory > m_rBridgeFactory; + Reference< XBridgeFactory2 > m_rBridgeFactory; OUString m_aAcceptString; OUString m_aConnectString; diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index ef16ea1b6a41..c3387f0ec0a5 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -51,6 +51,7 @@ #include "com/sun/star/lang/DisposedException.hpp" #include "boost/scoped_array.hpp" #include "com/sun/star/ui/dialogs/XDialogClosedListener.hpp" +#include "com/sun/star/bridge/BridgeFactory.hpp" #include "com/sun/star/bridge/XBridgeFactory.hpp" #include #include @@ -197,25 +198,19 @@ void disposeBridges(Reference ctx) if (!ctx.is()) return; - Reference bridgeFac( - ctx->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.bridge.BridgeFactory"), ctx), - UNO_QUERY); + Reference bridgeFac( css::bridge::BridgeFactory::create(ctx) ); - if (bridgeFac.is()) + const Sequence< Reference >seqBridges = bridgeFac->getExistingBridges(); + for (sal_Int32 i = 0; i < seqBridges.getLength(); i++) { - const Sequence< Reference >seqBridges = bridgeFac->getExistingBridges(); - for (sal_Int32 i = 0; i < seqBridges.getLength(); i++) + Reference comp(seqBridges[i], UNO_QUERY); + if (comp.is()) { - Reference comp(seqBridges[i], UNO_QUERY); - if (comp.is()) + try { + comp->dispose(); + } + catch ( const css::lang::DisposedException& ) { - try { - comp->dispose(); - } - catch ( const css::lang::DisposedException& ) - { - } } } } -- cgit