diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-09-14 18:08:57 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-14 18:24:49 +0200 |
commit | 9ac86f484b0c278aafbce685ed19d3ea005ee8f8 (patch) | |
tree | cf2fe16d76992bcbd1bd89a8693c5f4996cd55f2 /ucbhelper/source | |
parent | 2e284203da7f9882842111265f5f68ea0a145065 (diff) |
Improvement on previous commit, UCB clean up
* As UCB is only ever initialized with "Local"/"Office", remove this
configuration vector completely. The "create" ctor creates an instance
internally initialized with those "Local"/"Office" keys. Special (test) code
can still instantiate an uninitialized one via plain createInstance. And for
backwards compatilibity process startup still ensures to create an initialized
instance early, in case there is still code out there (in extensions) that
later calls plain createInstance and expects to get the already-initialized
(single) instance.
* XInitialization is an "implementation detail" of the UniversalContentBroker
service, do not expose in XUniversalContentBroker.
* ucbhelper/configurationkeys.hxx is no longer needed and is removed.
* ucbhelper/contentbroker.hxx is an empty wrapper and is removed; however, that
requires ucbhelper::Content constructors to take explicit XComponentContext
arguments now.
* The only remaining code in ucbhelper/source/client/contentbroker.cxx is
Android-only InitUCBHelper. Is that relevant still?
Change-Id: I3f7bddd0456bffbcd13590c66d9011915c760f28
Diffstat (limited to 'ucbhelper/source')
-rw-r--r-- | ucbhelper/source/client/content.cxx | 298 | ||||
-rw-r--r-- | ucbhelper/source/client/contentbroker.cxx | 343 | ||||
-rw-r--r-- | ucbhelper/source/client/fileidentifierconverter.cxx | 14 |
3 files changed, 108 insertions, 547 deletions
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx index 95106abb64c3..ec3b4544d62c 100644 --- a/ucbhelper/source/client/content.cxx +++ b/ucbhelper/source/client/content.cxx @@ -17,12 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "sal/config.h" -/************************************************************************** - TODO - ************************************************************************** +#include <cassert> - *************************************************************************/ #include <osl/diagnose.h> #include <osl/mutex.hxx> #include <salhelper/simplereferenceobject.hxx> @@ -48,6 +46,8 @@ #include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/ucb/XDynamicResultSet.hpp> #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp> +#include <com/sun/star/ucb/UniversalContentBroker.hpp> +#include <com/sun/star/ucb/XUniversalContentBroker.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -57,7 +57,6 @@ #include <com/sun/star/beans/UnknownPropertyException.hpp> #include <ucbhelper/macros.hxx> #include <ucbhelper/content.hxx> -#include <ucbhelper/contentbroker.hxx> #include <ucbhelper/activedatasink.hxx> #include <ucbhelper/activedatastreamer.hxx> #include <ucbhelper/interactionrequest.hxx> @@ -167,7 +166,7 @@ class Content_Impl : public salhelper::SimpleReferenceObject friend class ContentEventListener_Impl; mutable rtl::OUString m_aURL; - Reference< XMultiServiceFactory > m_xSMgr; + Reference< XComponentContext > m_xCtx; Reference< XContent > m_xContent; Reference< XCommandProcessor > m_xCommandProcessor; Reference< XCommandEnvironment > m_xEnv; @@ -181,7 +180,7 @@ private: public: Content_Impl() : m_nCommandId( 0 ) {}; - Content_Impl( const Reference< XMultiServiceFactory >& rSMgr, + Content_Impl( const Reference< XComponentContext >& rCtx, const Reference< XContent >& rContent, const Reference< XCommandEnvironment >& rEnv ); @@ -191,7 +190,8 @@ public: Reference< XContent > getContent(); Reference< XCommandProcessor > getCommandProcessor(); sal_Int32 getCommandId(); - Reference< XMultiServiceFactory > getServiceManager() { return m_xSMgr; } + Reference< XComponentContext > getComponentContext() + { assert(m_xCtx.is()); return m_xCtx; } Any executeCommand( const Command& rCommand ); @@ -206,109 +206,42 @@ public: // Helpers. //========================================================================= -static void ensureContentProviderForURL( const ContentBroker & rBroker, +static void ensureContentProviderForURL( const Reference< XUniversalContentBroker >& rBroker, const rtl::OUString & rURL ) throw ( ContentCreationException, RuntimeException ) { - Reference< XContentProviderManager > xMgr - = rBroker.getContentProviderManagerInterface(); - if ( !xMgr.is() ) + Reference< XContentProvider > xProv + = rBroker->queryContentProvider( rURL ); + if ( !xProv.is() ) { - throw RuntimeException( - rtl::OUString( - "UCB does not implement mandatory interface " - "XContentProviderManager!" ), - Reference< XInterface >() ); - } - else - { - Reference< XContentProvider > xProv - = xMgr->queryContentProvider( rURL ); - if ( !xProv.is() ) - { - throw ContentCreationException( - rtl::OUString( - "No Content Provider available for URL: ") + rURL, - Reference< XInterface >(), - ContentCreationError_NO_CONTENT_PROVIDER ); - } + throw ContentCreationException( + "No Content Provider available for URL: " + rURL, + Reference< XInterface >(), + ContentCreationError_NO_CONTENT_PROVIDER ); } } //========================================================================= -static ContentBroker* getContentBroker( bool bThrow ) - throw ( ContentCreationException, RuntimeException ) -{ - ContentBroker* pBroker = ContentBroker::get(); - - if ( !pBroker ) - { - if ( bThrow ) - throw RuntimeException( - rtl::OUString("No Content Broker!"), - Reference< XInterface >() ); - } - else - { -#if OSL_DEBUG_LEVEL > 1 - Reference< XContentProviderManager > xMgr - = pBroker->getContentProviderManagerInterface(); - if ( !xMgr.is() ) - { - if ( bThrow ) - throw RuntimeException( - rtl::OUString( - "UCB does not implement mandatory interface " - "XContentProviderManager!" ), - Reference< XInterface >() ); - } - else - { - OSL_ENSURE( xMgr->queryContentProviders().getLength(), - "Content Broker not configured (no providers)!" ); - } -#endif - } - - return pBroker; -} - -//========================================================================= static Reference< XContentIdentifier > getContentIdentifier( - const ContentBroker & rBroker, + const Reference< XUniversalContentBroker > & rBroker, const rtl::OUString & rURL, bool bThrow ) throw ( ContentCreationException, RuntimeException ) { - Reference< XContentIdentifierFactory > xIdFac - = rBroker.getContentIdentifierFactoryInterface(); - if ( xIdFac.is() ) - { - Reference< XContentIdentifier > xId - = xIdFac->createContentIdentifier( rURL ); - - if ( xId.is() ) - return xId; + Reference< XContentIdentifier > xId + = rBroker->createContentIdentifier( rURL ); - if ( bThrow ) - { - ensureContentProviderForURL( rBroker, rURL ); + if ( xId.is() ) + return xId; - throw ContentCreationException( - rtl::OUString( - "Unable to create Content Identifier!" ), - Reference< XInterface >(), - ContentCreationError_IDENTIFIER_CREATION_FAILED ); - } - } - else + if ( bThrow ) { - if ( bThrow ) - throw RuntimeException( - rtl::OUString( - "UCB does not implement mandatory interface " - "XContentIdentifierFactory!" ), - Reference< XInterface >() ); + ensureContentProviderForURL( rBroker, rURL ); + + throw ContentCreationException( + "Unable to create Content Identifier!", + Reference< XInterface >(), + ContentCreationError_IDENTIFIER_CREATION_FAILED ); } return Reference< XContentIdentifier >(); @@ -316,49 +249,34 @@ static Reference< XContentIdentifier > getContentIdentifier( //========================================================================= static Reference< XContent > getContent( - const ContentBroker & rBroker, + const Reference< XUniversalContentBroker > & rBroker, const Reference< XContentIdentifier > & xId, bool bThrow ) throw ( ContentCreationException, RuntimeException ) { - Reference< XContentProvider > xProvider - = rBroker.getContentProviderInterface(); - if ( xProvider.is() ) + Reference< XContent > xContent; + rtl::OUString msg; + try { - Reference< XContent > xContent; - rtl::OUString msg; - try - { - xContent = xProvider->queryContent( xId ); - } - catch ( IllegalIdentifierException const & e ) - { - msg = e.Message; - // handled below. - } - - if ( xContent.is() ) - return xContent; + xContent = rBroker->queryContent( xId ); + } + catch ( IllegalIdentifierException const & e ) + { + msg = e.Message; + // handled below. + } - if ( bThrow ) - { - ensureContentProviderForURL( rBroker, xId->getContentIdentifier() ); + if ( xContent.is() ) + return xContent; - throw ContentCreationException( - rtl::OUString( - "Unable to create Content! " ) + msg, - Reference< XInterface >(), - ContentCreationError_CONTENT_CREATION_FAILED ); - } - } - else + if ( bThrow ) { - if ( bThrow ) - throw RuntimeException( - rtl::OUString( - "UCB does not implement mandatory interface " - "XContentProvider!" ), - Reference< XInterface >() ); + ensureContentProviderForURL( rBroker, xId->getContentIdentifier() ); + + throw ContentCreationException( + "Unable to create Content! " + msg, + Reference< XInterface >(), + ContentCreationError_CONTENT_CREATION_FAILED ); } return Reference< XContent >(); @@ -379,27 +297,28 @@ Content::Content() //========================================================================= Content::Content( const rtl::OUString& rURL, - const Reference< XCommandEnvironment >& rEnv ) + const Reference< XCommandEnvironment >& rEnv, + const Reference< XComponentContext >& rCtx ) throw ( ContentCreationException, RuntimeException ) { - ContentBroker* pBroker = getContentBroker( true ); + Reference< XUniversalContentBroker > pBroker( + UniversalContentBroker::create( rCtx ) ); Reference< XContentIdentifier > xId - = getContentIdentifier( *pBroker, rURL, true ); + = getContentIdentifier( pBroker, rURL, true ); - Reference< XContent > xContent = getContent( *pBroker, xId, true ); + Reference< XContent > xContent = getContent( pBroker, xId, true ); - m_xImpl = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv ); + m_xImpl = new Content_Impl( rCtx, xContent, rEnv ); } //========================================================================= Content::Content( const Reference< XContent >& rContent, - const Reference< XCommandEnvironment >& rEnv ) + const Reference< XCommandEnvironment >& rEnv, + const Reference< XComponentContext >& rCtx ) throw ( ContentCreationException, RuntimeException ) { - ContentBroker* pBroker = getContentBroker( true ); - - m_xImpl = new Content_Impl( pBroker->getServiceManager(), rContent, rEnv ); + m_xImpl = new Content_Impl( rCtx, rContent, rEnv ); } //========================================================================= @@ -412,23 +331,23 @@ Content::Content( const Content& rOther ) // static sal_Bool Content::create( const rtl::OUString& rURL, const Reference< XCommandEnvironment >& rEnv, + const Reference< XComponentContext >& rCtx, Content& rContent ) { - ContentBroker* pBroker = getContentBroker( false ); - if ( !pBroker ) - return sal_False; + Reference< XUniversalContentBroker > pBroker( + UniversalContentBroker::create( rCtx ) ); Reference< XContentIdentifier > xId - = getContentIdentifier( *pBroker, rURL, false ); + = getContentIdentifier( pBroker, rURL, false ); if ( !xId.is() ) return sal_False; - Reference< XContent > xContent = getContent( *pBroker, xId, false ); + Reference< XContent > xContent = getContent( pBroker, xId, false ); if ( !xContent.is() ) return sal_False; rContent.m_xImpl - = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv ); + = new Content_Impl( rCtx, xContent, rEnv ); return sal_True; } @@ -738,12 +657,12 @@ Reference< XResultSet > Content::createSortedCursor( if( aDynSet.is() ) { Reference< XDynamicResultSet > aDynResult; - Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager(); + Reference< XMultiComponentFactory > aServiceManager = m_xImpl->getComponentContext()->getServiceManager(); if( aServiceManager.is() ) { - Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance( - rtl::OUString("com.sun.star.ucb.SortedDynamicResultSetFactory")), + Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstanceWithContext( + "com.sun.star.ucb.SortedDynamicResultSetFactory", m_xImpl->getComponentContext()), UNO_QUERY ); aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet, @@ -1024,7 +943,8 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, return sal_False; } - Content aNewContent( xNew, m_xImpl->getEnvironment() ); + Content aNewContent( + xNew, m_xImpl->getEnvironment(), m_xImpl->getComponentContext() ); aNewContent.setPropertyValues( rPropertyNames, rPropertyValues ); aNewContent.executeCommand( rtl::OUString("insert"), makeAny( @@ -1044,20 +964,8 @@ sal_Bool Content::transferContent( const Content& rSourceContent, const sal_Int32 nNameClashAction ) throw( CommandAbortedException, RuntimeException, Exception ) { - ContentBroker* pBroker = ContentBroker::get(); - if ( !pBroker ) - { - OSL_FAIL( "Content::transferContent - No Content Broker!" ); - return sal_False; - } - - Reference< XCommandProcessor > xCmdProc( - pBroker->getCommandProcessorInterface() ); - if ( !xCmdProc.is() ) - { - OSL_FAIL( "Content::transferContent - No XCommandProcessor!" ); - return sal_False; - } + Reference< XUniversalContentBroker > pBroker( + UniversalContentBroker::create( m_xImpl->getComponentContext() ) ); // Execute command "globalTransfer" at UCB. @@ -1098,7 +1006,7 @@ sal_Bool Content::transferContent( const Content& rSourceContent, aCommand.Handle = -1; // n/a aCommand.Argument <<= aTransferArg; - xCmdProc->execute( aCommand, 0, m_xImpl->getEnvironment() ); + pBroker->execute( aCommand, 0, m_xImpl->getEnvironment() ); return sal_True; } @@ -1152,14 +1060,15 @@ sal_Bool Content::isDocument() //========================================================================= //========================================================================= -Content_Impl::Content_Impl( const Reference< XMultiServiceFactory >& rSMgr, +Content_Impl::Content_Impl( const Reference< XComponentContext >& rCtx, const Reference< XContent >& rContent, const Reference< XCommandEnvironment >& rEnv ) -: m_xSMgr( rSMgr ), +: m_xCtx( rCtx ), m_xContent( rContent ), m_xEnv( rEnv ), m_nCommandId( 0 ) { + assert(rCtx.is()); if ( m_xContent.is() ) { m_xContentEventListener = new ContentEventListener_Impl( *this ); @@ -1288,51 +1197,30 @@ Reference< XContent > Content_Impl::getContent() if ( !m_xContent.is() && !m_aURL.isEmpty() ) { - ContentBroker* pBroker = ContentBroker::get(); + Reference< XUniversalContentBroker > pBroker( + UniversalContentBroker::create( getComponentContext() ) ); - OSL_ENSURE( pBroker, "No Content Broker!" ); - - if ( pBroker ) - { - OSL_ENSURE( pBroker->getContentProviderManagerInterface() - ->queryContentProviders().getLength(), - "Content Broker not configured (no providers)!" ); + OSL_ENSURE( pBroker->queryContentProviders().getLength(), + "Content Broker not configured (no providers)!" ); - Reference< XContentIdentifierFactory > xIdFac - = pBroker->getContentIdentifierFactoryInterface(); + Reference< XContentIdentifier > xId + = pBroker->createContentIdentifier( m_aURL ); - OSL_ENSURE( xIdFac.is(), "No Content Identifier factory!" ); + OSL_ENSURE( xId.is(), "No Content Identifier!" ); - if ( xIdFac.is() ) + if ( xId.is() ) + { + try + { + m_xContent = pBroker->queryContent( xId ); + } + catch ( IllegalIdentifierException const & ) { - Reference< XContentIdentifier > xId - = xIdFac->createContentIdentifier( m_aURL ); - - OSL_ENSURE( xId.is(), "No Content Identifier!" ); - - if ( xId.is() ) - { - Reference< XContentProvider > xProvider - = pBroker->getContentProviderInterface(); - - OSL_ENSURE( xProvider.is(), "No Content Provider!" ); - - if ( xProvider.is() ) - { - try - { - m_xContent = xProvider->queryContent( xId ); - } - catch ( IllegalIdentifierException const & ) - { - } - - if ( m_xContent.is() ) - m_xContent->addContentEventListener( - m_xContentEventListener ); - } - } } + + if ( m_xContent.is() ) + m_xContent->addContentEventListener( + m_xContentEventListener ); } } } diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx index 219a7a13d077..24cec09b7ea5 100644 --- a/ucbhelper/source/client/contentbroker.cxx +++ b/ucbhelper/source/client/contentbroker.cxx @@ -17,194 +17,25 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "sal/config.h" -/************************************************************************** - TODO - ************************************************************************** +#ifdef ANDROID - *************************************************************************/ -#include <osl/diagnose.h> -#include <osl/mutex.hxx> -#include <rtl/instance.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/ucb/UniversalContentBroker.hpp> -#include <com/sun/star/ucb/XContentIdentifierFactory.hpp> -#include <com/sun/star/ucb/XContentProvider.hpp> -#include <com/sun/star/ucb/XContentProviderManager.hpp> -#include <com/sun/star/ucb/XCommandProcessor.hpp> -#include <ucbhelper/contentbroker.hxx> - -#ifdef ANDROID -#include <cppuhelper/bootstrap.hxx> #include <com/sun/star/uno/XComponentContext.hpp> -#include <ucbhelper/configurationkeys.hxx> -#endif +#include <cppuhelper/bootstrap.hxx> -using namespace com::sun::star::beans; -using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::uno; -using ::rtl::OUString; - -namespace -{ - struct theContentBrokerMutex : public rtl::Static< osl::Mutex, theContentBrokerMutex > {}; -} // namespace - -namespace ucbhelper -{ - -//========================================================================= -//========================================================================= -// -// class ContentBroker_Impl. -// -//========================================================================= -//========================================================================= - -class ContentBroker_Impl -{ - Reference< XMultiServiceFactory > m_xSMgr; - Reference< XContentIdentifierFactory > m_xIdFac; - Reference< XContentProvider > m_xProvider; - Reference< XContentProviderManager > m_xProviderMgr; - Reference< XCommandProcessor > m_xCommandProc; - osl::Mutex m_aMutex; - Sequence< Any > m_aArguments; - ContentProviderDataList m_aProvData; - bool m_bInitDone; - -public: - ContentBroker_Impl( const Reference< XMultiServiceFactory >& rSMgr, - const Sequence< Any >& rArguments ) - : m_xSMgr( rSMgr ), m_aArguments( rArguments ), m_bInitDone( sal_False ) - {} - - ContentBroker_Impl( const Reference< XMultiServiceFactory >& rSMgr, - const ContentProviderDataList & rData ) - : m_xSMgr( rSMgr ), m_aProvData( rData ), m_bInitDone( sal_False ) - {} - - ~ContentBroker_Impl(); - - bool initialize(); - - const Reference< XMultiServiceFactory >& getServiceManager() const - { return m_xSMgr; } - - const Reference< XContentIdentifierFactory >& getIdFactory() const - { return m_xIdFac; } - - const Reference< XContentProvider >& getProvider() const - { return m_xProvider; } - - const Reference< XContentProviderManager >& getProviderManager() const - { return m_xProviderMgr; } - - const Reference< XCommandProcessor >& getCommandProcessor() const - { return m_xCommandProc; } -}; - -//========================================================================= -//========================================================================= -// -// ContentBroker Implementation. -// -//========================================================================= -//========================================================================= - -// static member! -ContentBroker* ContentBroker::m_pTheBroker = 0; - -//========================================================================= -ContentBroker::ContentBroker( const Reference< XMultiServiceFactory >& rSMgr, - const Sequence< Any >& rArguments ) -{ - m_pImpl = new ContentBroker_Impl( rSMgr, rArguments ); -} - -//========================================================================= -ContentBroker::~ContentBroker() -{ - delete m_pImpl; -} - -//========================================================================= -Reference< XMultiServiceFactory > ContentBroker::getServiceManager() const -{ - return m_pImpl->getServiceManager(); -} - -//========================================================================= -Reference< XContentIdentifierFactory > - ContentBroker::getContentIdentifierFactoryInterface() const -{ - return m_pImpl->getIdFactory(); -} - -//========================================================================= -Reference< XContentProvider > - ContentBroker::getContentProviderInterface() const -{ - return m_pImpl->getProvider(); -} - -//========================================================================= -Reference< XContentProviderManager > - ContentBroker::getContentProviderManagerInterface() const -{ - return m_pImpl->getProviderManager(); -} - -//========================================================================= -Reference< XCommandProcessor > - ContentBroker::getCommandProcessorInterface() const -{ - return m_pImpl->getCommandProcessor(); -} - -//========================================================================= -// static -sal_Bool ContentBroker::initialize( - const Reference< XMultiServiceFactory >& rSMgr, - const Sequence< Any >& rArguments ) -{ - OSL_ENSURE( !m_pTheBroker, - "ContentBroker::initialize - already initialized!" ); - - if ( !m_pTheBroker ) - { - osl::Guard< osl::Mutex > aGuard( theContentBrokerMutex::get() ); - - if ( !m_pTheBroker ) - { - ContentBroker * pBroker = new ContentBroker( rSMgr, rArguments ); - - // Force init to be able to detect UCB init trouble immediately. - if ( pBroker->m_pImpl->initialize() ) - m_pTheBroker = pBroker; - else - delete pBroker; - } - } - - return m_pTheBroker != 0; -} - -#ifdef ANDROID - +//TODO: Is this relevant still? extern "C" __attribute__ ((visibility("default"))) void InitUCBHelper() { - Reference< XMultiServiceFactory > xFactory; + Reference< XComponentContext > xCtx; try { Reference< XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext(); - xFactory = Reference< XMultiServiceFactory >( xCtx->getServiceManager(), - UNO_QUERY ); } catch( Exception& ) { @@ -217,169 +48,11 @@ InitUCBHelper() exit( 1 ); } - // Create UCB. - Sequence< Any > aArgs( 2 ); - aArgs[ 0 ] <<= rtl::OUString( UCB_CONFIGURATION_KEY1_LOCAL ); - aArgs[ 1 ] <<= rtl::OUString( UCB_CONFIGURATION_KEY2_OFFICE ); - ::ucbhelper::ContentBroker::initialize( xFactory, aArgs ); + // Create UCB (for backwards compatibility, in case some code still uses + // plain createInstance w/o args directly to obtain an instance): + UniversalContentBroker::create( xCtx ); } #endif -//========================================================================= -// static -void ContentBroker::deinitialize() -{ - osl::MutexGuard aGuard( theContentBrokerMutex::get() ); - - delete m_pTheBroker; - m_pTheBroker = 0; -} - -//========================================================================= -// static -ContentBroker* ContentBroker::get() -{ - return m_pTheBroker; -} - -//========================================================================= -//========================================================================= -// -// ContentBroker_Impl Implementation. -// -//========================================================================= -//========================================================================= - -ContentBroker_Impl::~ContentBroker_Impl() -{ - Reference< XComponent > xComponent( m_xProvider, UNO_QUERY ); - if ( xComponent.is() ) - { - m_xIdFac = 0; - m_xProvider = 0; - m_xProviderMgr = 0; - - xComponent->dispose(); - } -} - -//========================================================================= -bool ContentBroker_Impl::initialize() -{ - if ( !m_bInitDone ) - { - osl::MutexGuard aGuard( m_aMutex ); - - if ( !m_bInitDone ) - { - Reference< XInterface > xIfc; - - if ( m_aProvData.size() > 0 ) - { - try - { - xIfc = m_xSMgr->createInstance( - OUString( - "com.sun.star.ucb.UniversalContentBroker" ) ); - } - catch ( Exception const & ) - { - } - - if ( xIfc.is() ) - { - m_xProviderMgr - = Reference< XContentProviderManager >( xIfc, UNO_QUERY ); - - if ( m_xProviderMgr.is() ) - { - ContentProviderDataList::const_iterator aEnd(m_aProvData.end()); - for (ContentProviderDataList::const_iterator aIt(m_aProvData.begin()); - aIt != aEnd; ++aIt) - { - registerAtUcb(m_xProviderMgr, - m_xSMgr, - aIt->ServiceName, - aIt->Arguments, - aIt->URLTemplate, - 0); - } - - } - } - } - else - { - try - { - Reference< XPropertySet > xFactoryProperties( m_xSMgr, UNO_QUERY_THROW ); - Reference< XComponentContext > xContext( xFactoryProperties->getPropertyValue( "DefaultContext" ), UNO_QUERY_THROW ); - if( m_aArguments.getLength() == 0 ) - xIfc = UniversalContentBroker::createDefault(xContext); - else - { - rtl::OUString aPrimaryConfigKey, aSecondaryConfigKey; - m_aArguments[0] >>= aPrimaryConfigKey; - m_aArguments[1] >>= aSecondaryConfigKey; - xIfc = UniversalContentBroker::createWithKeys(xContext, aPrimaryConfigKey, aSecondaryConfigKey); - } - } - catch ( const Exception & e) - { - SAL_WARN("ucbhelper", "exception while initialising UniversalContentBroker " << e.Message); - } - } - - OSL_ENSURE( xIfc.is(), "Error creating UCB service 'com.sun.star.ucb.UniversalContentBroker'" ); - - if ( !xIfc.is() ) - return false; - - - m_xIdFac - = Reference< XContentIdentifierFactory >( xIfc, UNO_QUERY ); - - OSL_ENSURE( m_xIdFac.is(), - "UCB without required interface XContentIdentifierFactory!" ); - - if ( !m_xIdFac.is() ) - return false; - - m_xProvider = Reference< XContentProvider >( xIfc, UNO_QUERY ); - - OSL_ENSURE( m_xProvider.is(), - "UCB without required interface XContentProvider!" ); - - if ( !m_xProvider.is() ) - return false; - - if ( !m_xProviderMgr.is() ) - m_xProviderMgr - = Reference< XContentProviderManager >( xIfc, UNO_QUERY ); - - OSL_ENSURE( m_xProviderMgr.is(), - "UCB without required interface XContentProviderManager!" ); - - if ( !m_xProviderMgr.is() ) - return false; - - m_xCommandProc = Reference< XCommandProcessor >( xIfc, UNO_QUERY ); - - OSL_ENSURE( m_xCommandProc.is(), - "UCB without required interface XCommandProcessor!" ); - - if ( !m_xCommandProc.is() ) - return false; - - // Everything okay. - m_bInitDone = sal_True; - } - } - - return true; -} - -} /* namespace ucbhelper */ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucbhelper/source/client/fileidentifierconverter.cxx b/ucbhelper/source/client/fileidentifierconverter.cxx index 3771d0d3c20e..4e0e28850b03 100644 --- a/ucbhelper/source/client/fileidentifierconverter.cxx +++ b/ucbhelper/source/client/fileidentifierconverter.cxx @@ -19,8 +19,8 @@ #include <ucbhelper/fileidentifierconverter.hxx> #include <com/sun/star/ucb/ContentProviderInfo.hpp> -#include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/ucb/XFileIdentifierConverter.hpp> +#include <com/sun/star/ucb/XUniversalContentBroker.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <osl/diagnose.h> @@ -55,15 +55,15 @@ getLocalFileURL() SAL_THROW((uno::RuntimeException)) rtl::OUString getFileURLFromSystemPath( - uno::Reference< ucb::XContentProviderManager > const & rManager, + uno::Reference< ucb::XUniversalContentBroker > const & rUcb, rtl::OUString const & rBaseURL, rtl::OUString const & rSystemPath) SAL_THROW((uno::RuntimeException)) { - OSL_ASSERT(rManager.is()); + OSL_ASSERT(rUcb.is()); uno::Reference< ucb::XFileIdentifierConverter > - xConverter(rManager->queryContentProvider(rBaseURL), uno::UNO_QUERY); + xConverter(rUcb->queryContentProvider(rBaseURL), uno::UNO_QUERY); if (xConverter.is()) return xConverter->getFileURLFromSystemPath(rBaseURL, rSystemPath); else @@ -78,14 +78,14 @@ getFileURLFromSystemPath( rtl::OUString getSystemPathFromFileURL( - uno::Reference< ucb::XContentProviderManager > const & rManager, + uno::Reference< ucb::XUniversalContentBroker > const & rUcb, rtl::OUString const & rURL) SAL_THROW((uno::RuntimeException)) { - OSL_ASSERT(rManager.is()); + OSL_ASSERT(rUcb.is()); uno::Reference< ucb::XFileIdentifierConverter > - xConverter(rManager->queryContentProvider(rURL), uno::UNO_QUERY); + xConverter(rUcb->queryContentProvider(rURL), uno::UNO_QUERY); if (xConverter.is()) return xConverter->getSystemPathFromFileURL(rURL); else |