From a1afcae81ca3c4b6bb240263b3259090d48c7715 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 4 Jun 2013 16:35:09 +0200 Subject: fdo#46808, Convert XMultiServiceFactory in ucb module Change-Id: I4e1cfe22ba6043521dd1237f90ade66f80b29253 --- include/ucbhelper/registerucb.hxx | 5 ++-- ucb/source/cacher/cacheddynamicresultset.cxx | 12 +++++----- ucb/source/cacher/cacheddynamicresultset.hxx | 6 ++--- ucb/source/core/identify.cxx | 4 +--- ucb/source/core/identify.hxx | 4 +--- ucb/source/core/ucb.cxx | 24 ++++++++++---------- ucb/source/core/ucb.hxx | 4 ++-- ucb/source/core/ucbcmds.cxx | 26 ++++++++------------- ucb/source/core/ucbstore.cxx | 34 +++++++++++++--------------- ucb/source/core/ucbstore.hxx | 12 +++++----- ucbhelper/source/provider/registerucb.cxx | 14 ++++-------- 11 files changed, 64 insertions(+), 81 deletions(-) diff --git a/include/ucbhelper/registerucb.hxx b/include/ucbhelper/registerucb.hxx index 1c58fc1b682b..183dabdf6d06 100644 --- a/include/ucbhelper/registerucb.hxx +++ b/include/ucbhelper/registerucb.hxx @@ -30,6 +30,7 @@ namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } + namespace uno { class XComponentContext; } } } } @@ -108,8 +109,8 @@ UCBHELPER_DLLPUBLIC bool registerAtUcb( com::sun::star::ucb::XContentProviderManager > const & rManager, com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, + com::sun::star::uno::XComponentContext > const & + rxContext, OUString const & rName, OUString const & rArguments, OUString const & rTemplate, diff --git a/ucb/source/cacher/cacheddynamicresultset.cxx b/ucb/source/cacher/cacheddynamicresultset.cxx index 8b9f1a9a6959..ab6d880bdb21 100644 --- a/ucb/source/cacher/cacheddynamicresultset.cxx +++ b/ucb/source/cacher/cacheddynamicresultset.cxx @@ -33,8 +33,8 @@ using namespace com::sun::star::uno; CachedDynamicResultSet::CachedDynamicResultSet( Reference< XDynamicResultSet > xOrigin , const Reference< XContentIdentifierMapping > & xContentMapping - , const Reference< XMultiServiceFactory > & xSMgr ) - : DynamicResultSetWrapper( xOrigin, comphelper::getComponentContext(xSMgr) ) + , const Reference< XComponentContext > & xContext ) + : DynamicResultSetWrapper( xOrigin, xContext ) , m_xContentIdentifierMapping( xContentMapping ) { impl_init(); @@ -133,9 +133,9 @@ void SAL_CALL CachedDynamicResultSet //-------------------------------------------------------------------------- CachedDynamicResultSetFactory::CachedDynamicResultSetFactory( - const Reference< XMultiServiceFactory > & rSMgr ) + const Reference< XComponentContext > & xContext ) { - m_xSMgr = rSMgr; + m_xContext = xContext; } CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory() @@ -164,7 +164,7 @@ XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory, // CachedDynamicResultSetFactory XServiceInfo methods. //-------------------------------------------------------------------------- -XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory, +XSERVICEINFO_IMPL_1_CTX( CachedDynamicResultSetFactory, OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" ), OUString( CACHED_DRS_FACTORY_NAME ) ); @@ -186,7 +186,7 @@ Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory throw( RuntimeException ) { Reference< XDynamicResultSet > xRet; - xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr ); + xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xContext ); return xRet; } diff --git a/ucb/source/cacher/cacheddynamicresultset.hxx b/ucb/source/cacher/cacheddynamicresultset.hxx index 18dd49a0d41c..6b7c84fb93cb 100644 --- a/ucb/source/cacher/cacheddynamicresultset.hxx +++ b/ucb/source/cacher/cacheddynamicresultset.hxx @@ -51,7 +51,7 @@ public: , const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifierMapping > & xContentMapping , const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > & xSMgr ); + com::sun::star::uno::XComponentContext > & xContext ); virtual ~CachedDynamicResultSet(); @@ -87,13 +87,13 @@ class CachedDynamicResultSetFactory { protected: com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::XComponentContext > m_xContext; public: CachedDynamicResultSetFactory( const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > & rSMgr); + com::sun::star::uno::XComponentContext > & xContext); virtual ~CachedDynamicResultSetFactory(); diff --git a/ucb/source/core/identify.cxx b/ucb/source/core/identify.cxx index 209aeeda0c44..53d0dff03aaf 100644 --- a/ucb/source/core/identify.cxx +++ b/ucb/source/core/identify.cxx @@ -38,10 +38,8 @@ using namespace com::sun::star::ucb; //========================================================================= ContentIdentifier::ContentIdentifier( - const Reference< XMultiServiceFactory >& rxSMgr, const OUString& ContentId ) -: m_xSMgr( rxSMgr ), - m_aContentId( ContentId ) +: m_aContentId( ContentId ) { } diff --git a/ucb/source/core/identify.hxx b/ucb/source/core/identify.hxx index 8c504f7a5e75..753257871ce5 100644 --- a/ucb/source/core/identify.hxx +++ b/ucb/source/core/identify.hxx @@ -35,8 +35,7 @@ class ContentIdentifier : public com::sun::star::ucb::XContentIdentifier { public: - ContentIdentifier( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr, - const OUString& ContentId ); + ContentIdentifier( const OUString& ContentId ); virtual ~ContentIdentifier(); // XInterface @@ -52,7 +51,6 @@ public: throw( com::sun::star::uno::RuntimeException ); private: - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; OUString m_aContentId; OUString m_aProviderScheme; }; diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index 493ff514f5ec..3d45c7f621c8 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -231,13 +231,13 @@ bool createContentProviderData( //========================================================================= UniversalContentBroker::UniversalContentBroker( - const Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr ) -: m_xSMgr( rXSMgr ), + const Reference< com::sun::star::uno::XComponentContext >& xContext ) +: m_xContext( xContext ), m_pDisposeEventListeners( NULL ), m_nInitCount( 0 ), //@@@ see initialize() method m_nCommandId( 0 ) { - OSL_ENSURE( m_xSMgr.is(), + OSL_ENSURE( m_xContext.is(), "UniversalContentBroker ctor: No service manager" ); } @@ -333,7 +333,7 @@ void SAL_CALL UniversalContentBroker::removeEventListener( // //========================================================================= -XSERVICEINFO_IMPL_1( UniversalContentBroker, +XSERVICEINFO_IMPL_1_CTX( UniversalContentBroker, OUString( "com.sun.star.comp.ucb.UniversalContentBroker" ), OUString( UCB_SERVICE_NAME ) ); @@ -598,7 +598,7 @@ Reference< XContentIdentifier > SAL_CALL } if ( !xIdentifier.is() ) - xIdentifier = new ContentIdentifier( m_xSMgr, ContentId ); + xIdentifier = new ContentIdentifier( ContentId ); return xIdentifier; } @@ -846,11 +846,11 @@ void UniversalContentBroker::prepareAndRegister( &aProviderArguments)) { registerAtUcb(this, - m_xSMgr, - aIt->ServiceName, - aProviderArguments, - aIt->URLTemplate, - 0); + m_xContext, + aIt->ServiceName, + aProviderArguments, + aIt->URLTemplate, + 0); } else @@ -864,7 +864,7 @@ bool UniversalContentBroker::getContentProviderData( const OUString & rKey2, ContentProviderDataList & rListToFill ) { - if ( !m_xSMgr.is() || rKey1.isEmpty() || rKey2.isEmpty() ) + if ( !m_xContext.is() || rKey1.isEmpty() || rKey2.isEmpty() ) { OSL_FAIL( "UniversalContentBroker::getContentProviderData - Invalid argument!" ); return false; @@ -873,7 +873,7 @@ bool UniversalContentBroker::getContentProviderData( try { uno::Reference< lang::XMultiServiceFactory > xConfigProv = - configuration::theDefaultProvider::get( comphelper::getComponentContext(m_xSMgr) ); + configuration::theDefaultProvider::get( m_xContext ); OUStringBuffer aFullPath; aFullPath.appendAscii( CONFIG_CONTENTPROVIDERS_KEY "/['" ); diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx index 50d5d699cc16..54e215b4341d 100644 --- a/ucb/source/core/ucb.hxx +++ b/ucb/source/core/ucb.hxx @@ -62,7 +62,7 @@ class UniversalContentBroker : public com::sun::star::util::XChangesListener { public: - UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); + UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext ); virtual ~UniversalContentBroker(); // XInterface @@ -198,7 +198,7 @@ private: void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData); com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::XComponentContext > m_xContext; com::sun::star::uno::Reference< com::sun::star::util::XChangesNotifier > m_xNotifier; diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx index 3c4fdd71fe02..b1f9e26bc04e 100644 --- a/ucb/source/core/ucbcmds.cxx +++ b/ucb/source/core/ucbcmds.cxx @@ -76,19 +76,19 @@ namespace struct TransferCommandContext { - uno::Reference< lang::XMultiServiceFactory > xSMgr; + uno::Reference< uno::XComponentContext > m_xContext; uno::Reference< ucb::XCommandProcessor > xProcessor; uno::Reference< ucb::XCommandEnvironment > xEnv; uno::Reference< ucb::XCommandEnvironment > xOrigEnv; ucb::GlobalTransferCommandArgument2 aArg; TransferCommandContext( - const uno::Reference< lang::XMultiServiceFactory > & rxSMgr, + const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< ucb::XCommandProcessor > & rxProcessor, const uno::Reference< ucb::XCommandEnvironment > & rxEnv, const uno::Reference< ucb::XCommandEnvironment > & rxOrigEnv, const ucb::GlobalTransferCommandArgument2 & rArg ) - : xSMgr( rxSMgr ), xProcessor( rxProcessor ), xEnv( rxEnv ), + : m_xContext( xContext ), xProcessor( rxProcessor ), xEnv( rxEnv ), xOrigEnv( rxOrigEnv ), aArg( rArg ) {} }; @@ -965,7 +965,7 @@ uno::Reference< io::XInputStream > getInputStream( try { - uno::Reference< io::XOutputStream > xOutputStream( io::Pipe::create(comphelper::getComponentContext(rContext.xSMgr)), uno::UNO_QUERY_THROW ); + uno::Reference< io::XOutputStream > xOutputStream( io::Pipe::create(rContext.m_xContext), uno::UNO_QUERY_THROW ); ucb::OpenCommandArgument2 aArg; aArg.Mode = ucb::OpenMode::DOCUMENT; @@ -1617,7 +1617,7 @@ void globalTransfer_( rContext.aArg.MimeType ); TransferCommandContext aSubCtx( - rContext.xSMgr, + rContext.m_xContext, rContext.xProcessor, rContext.xEnv, rContext.xOrigEnv, @@ -1704,11 +1704,8 @@ void UniversalContentBroker::globalTransfer( uno::Reference< ucb::XCommandEnvironment > xLocalEnv; if (xEnv.is()) { - uno::Reference< uno::XComponentContext > xCtx( - comphelper::getComponentContext( m_xSMgr ) ); - - xLocalEnv.set( ucb::CommandEnvironment::create( - xCtx, + xLocalEnv.set( ucb::CommandEnvironment::create( + m_xContext, new InteractionHandlerProxy( xEnv->getInteractionHandler() ), xEnv->getProgressHandler() ) ); } @@ -1994,7 +1991,7 @@ void UniversalContentBroker::globalTransfer( } TransferCommandContext aTransferCtx( - m_xSMgr, this, xLocalEnv, xEnv, rArg ); + m_xContext, this, xLocalEnv, xEnv, rArg ); if ( rArg.NewTitle.isEmpty() ) { @@ -2045,11 +2042,8 @@ uno::Any UniversalContentBroker::checkIn( const ucb::CheckinArgument& rArg, uno::Reference< ucb::XCommandEnvironment > xLocalEnv; if (xEnv.is()) { - uno::Reference< uno::XComponentContext > xCtx( - comphelper::getComponentContext( m_xSMgr ) ); - - xLocalEnv.set( ucb::CommandEnvironment::create( - xCtx, + xLocalEnv.set( ucb::CommandEnvironment::create( + m_xContext, new InteractionHandlerProxy( xEnv->getInteractionHandler() ), xEnv->getProgressHandler() ) ); } diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx index 319a9457a48b..ee7030c15ff5 100644 --- a/ucb/source/core/ucbstore.cxx +++ b/ucb/source/core/ucbstore.cxx @@ -142,12 +142,12 @@ PropertySetMap_Impl; class PropertySetInfo_Impl : public OWeakObject, public XTypeProvider, public XPropertySetInfo { - Reference< XMultiServiceFactory > m_xSMgr; + Reference< XComponentContext > m_xContext; Sequence< Property >* m_pProps; PersistentPropertySet* m_pOwner; public: - PropertySetInfo_Impl( const Reference< XMultiServiceFactory >& rxSMgr, + PropertySetInfo_Impl( const Reference< XComponentContext >& xContext, PersistentPropertySet* pOwner ); virtual ~PropertySetInfo_Impl(); @@ -192,8 +192,8 @@ struct UcbStore_Impl //========================================================================= //========================================================================= -UcbStore::UcbStore( const Reference< XMultiServiceFactory >& rXSMgr ) -: m_xSMgr( rXSMgr ), +UcbStore::UcbStore( const Reference< XComponentContext >& xContext ) +: m_xContext( xContext ), m_pImpl( new UcbStore_Impl() ) { } @@ -235,7 +235,7 @@ XTYPEPROVIDER_IMPL_4( UcbStore, // //========================================================================= -XSERVICEINFO_IMPL_1( UcbStore, +XSERVICEINFO_IMPL_1_CTX( UcbStore, OUString( "com.sun.star.comp.ucb.UcbStore" ), OUString( STORE_SERVICE_NAME ) ); @@ -265,7 +265,7 @@ UcbStore::createPropertySetRegistry( const OUString& ) { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); if ( !m_pImpl->m_xTheRegistry.is() ) - m_pImpl->m_xTheRegistry = new PropertySetRegistry( m_xSMgr, getInitArgs() ); + m_pImpl->m_xTheRegistry = new PropertySetRegistry( m_xContext, getInitArgs() ); } return m_pImpl->m_xTheRegistry; @@ -327,9 +327,9 @@ struct PropertySetRegistry_Impl //========================================================================= PropertySetRegistry::PropertySetRegistry( - const Reference< XMultiServiceFactory >& rXSMgr, + const Reference< XComponentContext >& xContext, const Sequence< Any > &rInitArgs ) -: m_xSMgr( rXSMgr ), +: m_xContext( xContext ), m_pImpl( new PropertySetRegistry_Impl( rInitArgs ) ) { } @@ -412,7 +412,7 @@ PropertySetRegistry::openPropertySet( const OUString& key, sal_Bool create ) // Yep! return Reference< XPersistentPropertySet >( new PersistentPropertySet( - m_xSMgr, *this, key ) ); + m_xContext, *this, key ) ); } else if ( create ) { @@ -460,7 +460,7 @@ PropertySetRegistry::openPropertySet( const OUString& key, sal_Bool create ) return Reference< XPersistentPropertySet >( new PersistentPropertySet( - m_xSMgr, *this, key ) ); + m_xContext, *this, key ) ); } } catch (const IllegalArgumentException&) @@ -1037,9 +1037,7 @@ Reference< XMultiServiceFactory > PropertySetRegistry::getConfigProvider() { try { - m_pImpl->m_xConfigProvider - = theDefaultProvider::get( - comphelper::getComponentContext( m_xSMgr ) ); + m_pImpl->m_xConfigProvider = theDefaultProvider::get( m_xContext ); } catch (const Exception&) { @@ -1263,10 +1261,10 @@ struct PersistentPropertySet_Impl //========================================================================= PersistentPropertySet::PersistentPropertySet( - const Reference< XMultiServiceFactory >& rXSMgr, + const Reference< XComponentContext >& xContext, PropertySetRegistry& rCreator, const OUString& rKey ) -: m_xSMgr( rXSMgr ), +: m_xContext( xContext ), m_pImpl( new PersistentPropertySet_Impl( rCreator, rKey ) ) { // register at creator. @@ -1401,7 +1399,7 @@ Reference< XPropertySetInfo > SAL_CALL PropertySetInfo_Impl*& rpInfo = m_pImpl->m_pInfo; if ( !rpInfo ) { - rpInfo = new PropertySetInfo_Impl( m_xSMgr, this ); + rpInfo = new PropertySetInfo_Impl( m_xContext, this ); rpInfo->acquire(); } return Reference< XPropertySetInfo >( rpInfo ); @@ -2361,9 +2359,9 @@ PropertySetRegistry& PersistentPropertySet::getPropertySetRegistry() //========================================================================= PropertySetInfo_Impl::PropertySetInfo_Impl( - const Reference< XMultiServiceFactory >& rxSMgr, + const Reference< XComponentContext >& xContext, PersistentPropertySet* pOwner ) -: m_xSMgr( rxSMgr ), +: m_xContext( xContext ), m_pProps( NULL ), m_pOwner( pOwner ) { diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx index 8364bd23dabb..2a9d70a8f42f 100644 --- a/ucb/source/core/ucbstore.hxx +++ b/ucb/source/core/ucbstore.hxx @@ -54,13 +54,13 @@ class UcbStore : public com::sun::star::lang::XInitialization { com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::XComponentContext > m_xContext; UcbStore_Impl* m_pImpl; public: UcbStore( const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); + com::sun::star::uno::XComponentContext >& xContext ); virtual ~UcbStore(); // XInterface @@ -104,7 +104,7 @@ class PropertySetRegistry : friend class PersistentPropertySet; com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::XComponentContext > m_xContext; PropertySetRegistry_Impl* m_pImpl; private: @@ -120,7 +120,7 @@ private: public: PropertySetRegistry( const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory >& rXSMgr, + com::sun::star::uno::XComponentContext >& xContext, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rInitArgs); virtual ~PropertySetRegistry(); @@ -187,7 +187,7 @@ class PersistentPropertySet : public com::sun::star::beans::XPropertyAccess { com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::XComponentContext > m_xContext; PersistentPropertySet_Impl* m_pImpl; private: @@ -199,7 +199,7 @@ private: public: PersistentPropertySet( const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory >& rXSMgr, + com::sun::star::uno::XComponentContext >& xContext, PropertySetRegistry& rCreator, const OUString& rKey ); virtual ~PersistentPropertySet(); diff --git a/ucbhelper/source/provider/registerucb.cxx b/ucbhelper/source/provider/registerucb.cxx index 944fe01f1abc..a17e0ad8bd6f 100644 --- a/ucbhelper/source/provider/registerucb.cxx +++ b/ucbhelper/source/provider/registerucb.cxx @@ -42,14 +42,14 @@ namespace ucbhelper { bool registerAtUcb( uno::Reference< ucb::XContentProviderManager > const & rManager, - uno::Reference< lang::XMultiServiceFactory > const & rServiceFactory, + uno::Reference< uno::XComponentContext > const & rxContext, OUString const & rName, OUString const & rArguments, OUString const & rTemplate, ContentProviderRegistrationInfo * pInfo) throw (uno::RuntimeException) { - OSL_ENSURE(rServiceFactory.is(), + OSL_ENSURE(rxContext.is(), "ucb::registerAtUcb(): No service factory"); bool bNoProxy = rArguments.startsWith("{noproxy}"); @@ -66,13 +66,7 @@ registerAtUcb( uno::Reference< ucb::XContentProviderFactory > xProxyFactory; try { - uno::Reference< beans::XPropertySet > xFactoryProperties( rServiceFactory, uno::UNO_QUERY_THROW ); - uno::Reference< uno::XComponentContext > xContext = uno::Reference< uno::XComponentContext >( - xFactoryProperties->getPropertyValue( OUString( "DefaultContext" ) ), - uno::UNO_QUERY ); - xProxyFactory - = uno::Reference< ucb::XContentProviderFactory >( - ucb::ContentProviderProxyFactory::create( xContext ) ); + xProxyFactory = ucb::ContentProviderProxyFactory::create( rxContext ); } catch (uno::Exception const &) {} OSL_ENSURE(xProxyFactory.is(), "No ContentProviderProxyFactory"); @@ -85,7 +79,7 @@ registerAtUcb( try { xProvider = uno::Reference< ucb::XContentProvider >( - rServiceFactory->createInstance(rName), + rxContext->getServiceManager()->createInstanceWithContext(rName, rxContext), uno::UNO_QUERY); } catch (uno::RuntimeException const &) { throw; } -- cgit