diff options
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/core/ucb.cxx | 183 | ||||
-rw-r--r-- | ucb/source/core/ucb.hxx | 112 |
2 files changed, 158 insertions, 137 deletions
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index 37f33ae5510d..bb0d7301aa83 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucb.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: sb $ $Date: 2000-12-05 16:42:52 $ + * last change: $Author: kso $ $Date: 2001-02-02 08:21:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -54,7 +54,7 @@ * * All Rights Reserved. * - * Contributor(s): _______________________________________ + * Contributor(s): Kai Sommerfeld ( kso@sun.com ) * * ************************************************************************/ @@ -65,9 +65,6 @@ *************************************************************************/ -#ifndef __HASH_SET__ -#include <stl/hash_set> -#endif #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ #include <cppuhelper/interfacecontainer.hxx> #endif @@ -77,6 +74,12 @@ #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ #include <com/sun/star/lang/IllegalArgumentException.hpp> #endif +#ifndef _COM_SUN_STAR_UCB_GLOBALTRANSFERCOMMANDARGUMENT_HPP_ +#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCOMMANDINFO_HPP_ +#include <com/sun/star/ucb/XCommandInfo.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_ #include <com/sun/star/ucb/XContentProvider.hpp> #endif @@ -90,6 +93,9 @@ #ifndef _IDENTIFY_HXX #include "identify.hxx" #endif +#ifndef _UCBCMDS_HXX +#include "ucbcmds.hxx" +#endif #include "ucb.hxx" @@ -107,37 +113,6 @@ using namespace com::sun::star::ucb; //========================================================================= // -// ContentInfoMap_Impl. -// -//========================================================================= - -struct equalStr_Impl -{ - bool operator()( const ContentInfo& i1, const ContentInfo& i2 ) const - { - return !!( i1.Type == i2.Type ); - } -}; - -struct hashStr_Impl -{ - size_t operator()( const ContentInfo& i ) const - { - return i.Type.hashCode(); - } -}; - -//========================================================================= -typedef std::hash_set -< - ContentInfo, - hashStr_Impl, - equalStr_Impl -> -ContentInfoMap_Impl; - -//========================================================================= -// // UniversalContentBroker Implementation. // //========================================================================= @@ -146,7 +121,8 @@ UniversalContentBroker::UniversalContentBroker( const Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr ) : m_xSMgr( rXSMgr ), m_pDisposeEventListeners( NULL ), - m_nInitCount( 0 ) //@@@ see initialize() method + m_nInitCount( 0 ), //@@@ see initialize() method + m_nCommandId( 0 ) { VOS_ENSURE( m_xSMgr.is(), "UniversalContentBroker ctor: No service manager" ); @@ -173,7 +149,7 @@ XINTERFACE_IMPL_8( UniversalContentBroker, XContentProviderManager, XContentProvider, XContentIdentifierFactory, - XContentCreator ); + XCommandProcessor ); //========================================================================= // @@ -189,7 +165,7 @@ XTYPEPROVIDER_IMPL_8( UniversalContentBroker, XContentProviderManager, XContentProvider, XContentIdentifierFactory, - XContentCreator ); + XCommandProcessor ); //========================================================================= // @@ -491,96 +467,83 @@ Reference< XContentIdentifier > SAL_CALL //========================================================================= // -// XContentCreator methods. +// XCommandProcessor methods. // //========================================================================= // virtual -com::sun::star::uno::Sequence< ContentInfo > SAL_CALL - UniversalContentBroker::queryCreatableContentsInfo() - throw( com::sun::star::uno::RuntimeException ) +sal_Int32 SAL_CALL UniversalContentBroker::createCommandIdentifier() + throw( RuntimeException ) { - ////////////////////////////////////////////////////////////////////// - // Iterate over providers, query info there and merge results. - ////////////////////////////////////////////////////////////////////// - - ContentInfoMap_Impl aInfoMap; - - osl::MutexGuard aGuard(m_aMutex); - - ProviderMap_Impl::const_iterator end = m_aProviders.end(); - for (ProviderMap_Impl::const_iterator it(m_aProviders.begin()); - it != end; ++it) - { - Reference< XContentCreator > - xCreator( it->getValue().front().getResolvedProvider(), UNO_QUERY ); - if ( xCreator.is() ) - { - com::sun::star::uno::Sequence< ContentInfo > aInfo = - xCreator->queryCreatableContentsInfo(); - sal_uInt32 nCount = aInfo.getLength(); - for ( sal_uInt32 n = 0; n < nCount; ++ n ) - { - const ContentInfo& rInfo = aInfo[ n ]; - - // Avoid duplicates. - if ( aInfoMap.find( rInfo ) == aInfoMap.end() ) - aInfoMap.insert( rInfo ); - } - } - } - - // Put collected info into sequence. - - sal_uInt32 nCount = aInfoMap.size(); - com::sun::star::uno::Sequence< ContentInfo > aSeq( nCount ); - ContentInfo* pInfo = aSeq.getArray(); - - ContentInfoMap_Impl::const_iterator iter = aInfoMap.begin(); - for ( sal_uInt32 n = 0; n < nCount; n++, iter++ ) - pInfo[ n ] = (*iter); + osl::MutexGuard aGuard( m_aMutex ); - return aSeq; + // Just increase counter on every call to generate an identifier. + return ++m_nCommandId; } //========================================================================= // virtual -Reference< XContent > SAL_CALL - UniversalContentBroker::createNewContent( const ContentInfo& Info ) - throw( com::sun::star::uno::RuntimeException ) +Any SAL_CALL UniversalContentBroker::execute( + const Command& aCommand, + sal_Int32 CommandId, + const Reference< XCommandEnvironment >& Environment ) + throw( Exception, CommandAbortedException, RuntimeException ) { + Any aRet; + ////////////////////////////////////////////////////////////////////// - // Find the matching content creator and delegate call. + // Note: Don't forget to adapt ucb_commands::CommandProcessorInfo + // ctor in ucbcmds.cxx when adding new commands! ////////////////////////////////////////////////////////////////////// - osl::MutexGuard aGuard(m_aMutex); + if ( ( aCommand.Handle == GETCOMMANDINFO_HANDLE ) || + ( aCommand.Name.compareToAscii( GETCOMMANDINFO_NAME ) == 0 ) ) + { + ////////////////////////////////////////////////////////////////// + // getCommandInfo + ////////////////////////////////////////////////////////////////// - ProviderMap_Impl::const_iterator end = m_aProviders.end(); - for (ProviderMap_Impl::const_iterator it(m_aProviders.begin()); it != end; - ++it) + aRet <<= getCommandInfo(); + } + else if ( ( aCommand.Handle == GLOBALTRANSFER_HANDLE ) || + ( aCommand.Name.compareToAscii( GLOBALTRANSFER_NAME ) == 0 ) ) { - // Note: Active provider is always the first list element. - Reference< XContentCreator > - xCreator( it->getValue().front().getResolvedProvider(), UNO_QUERY ); - if ( xCreator.is() ) + ////////////////////////////////////////////////////////////////// + // globalTransfer + ////////////////////////////////////////////////////////////////// + + GlobalTransferCommandArgument aTransferArg; + if ( aCommand.Argument >>= aTransferArg ) { - com::sun::star::uno::Sequence< ContentInfo > aInfo = - xCreator->queryCreatableContentsInfo(); - sal_uInt32 nCount = aInfo.getLength(); - for ( sal_uInt32 n = 0; n < nCount; ++ n ) - { - // Compare content types. - if ( aInfo[ n ].Type == Info.Type ) - { - // Found! - return xCreator->createNewContent( Info ); - } - } + globalTransfer( aTransferArg, Environment ); + } + else + { + VOS_ENSURE( sal_False, + "UniversalContentBroker::execute - invalid parameter!" ); + throw CommandAbortedException(); } } + else + { + ////////////////////////////////////////////////////////////////// + // Unknown command + ////////////////////////////////////////////////////////////////// - // No matching creator found. - return Reference< XContent >(); + VOS_ENSURE( sal_False, + "UniversalContentBroker::execute - unknown command!" ); + throw CommandAbortedException(); + } + + return aRet; +} + +//========================================================================= +// virtual +void SAL_CALL UniversalContentBroker::abort( sal_Int32 CommandId ) + throw( RuntimeException ) +{ + // @@@ Not implemeted ( yet). } //========================================================================= diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx index 1a9a4ab74af2..0b5c878d0c23 100644 --- a/ucb/source/core/ucb.hxx +++ b/ucb/source/core/ucb.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ucb.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $ + * last change: $Author: kso $ $Date: 2001-02-02 08:21:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -54,7 +54,7 @@ * * All Rights Reserved. * - * Contributor(s): _______________________________________ + * Contributor(s): Kai Sommerfeld ( kso@sun.com ) * * ************************************************************************/ @@ -62,15 +62,15 @@ #ifndef _UCB_HXX #define _UCB_HXX +#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_ +#include <com/sun/star/ucb/XCommandProcessor.hpp> +#endif #ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_ #include <com/sun/star/ucb/XContentProvider.hpp> #endif #ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIERFACTORY_HPP_ #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> #endif -#ifndef _COM_SUN_STAR_UCB_XCONTENTCREATOR_HPP_ -#include <com/sun/star/ucb/XContentCreator.hpp> -#endif #ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDERMANAGER_HPP_ #include <com/sun/star/ucb/XContentProviderManager.hpp> #endif @@ -120,6 +120,11 @@ namespace cppu { class OInterfaceContainerHelper; } +namespace com { namespace sun { namespace star { namespace ucb { + class XCommandInfo; + struct GlobalTransferCommandArgument; +} } } } + class UniversalContentBroker : public cppu::OWeakObject, public com::sun::star::lang::XTypeProvider, @@ -129,7 +134,7 @@ class UniversalContentBroker : public com::sun::star::ucb::XContentProviderManager, public com::sun::star::ucb::XContentProvider, public com::sun::star::ucb::XContentIdentifierFactory, - public com::sun::star::ucb::XContentCreator + public com::sun::star::ucb::XCommandProcessor { public: UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); @@ -145,54 +150,107 @@ public: XSERVICEINFO_DECL() // XComponent - virtual void SAL_CALL dispose() + virtual void SAL_CALL + dispose() throw( com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& Listener ) + virtual void SAL_CALL + addEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) throw( com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& Listener ) + virtual void SAL_CALL + removeEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) throw( com::sun::star::uno::RuntimeException ); // XInitialization - virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) - throw( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + initialize( const com::sun::star::uno::Sequence< + com::sun::star::uno::Any >& aArguments ) + throw( com::sun::star::uno::Exception, + com::sun::star::uno::RuntimeException ); // XContentProviderManager - virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > SAL_CALL registerContentProvider( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >& Provider, const rtl::OUString& Scheme, sal_Bool ReplaceExisting ) - throw( com::sun::star::ucb::DuplicateProviderException, com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL deregisterContentProvider( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >& Provider, const rtl::OUString& Scheme ) + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProvider > SAL_CALL + registerContentProvider( const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProvider >& + Provider, + const rtl::OUString& Scheme, + sal_Bool ReplaceExisting ) + throw( com::sun::star::ucb::DuplicateProviderException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + deregisterContentProvider( const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProvider >& + Provider, + const rtl::OUString& Scheme ) throw( com::sun::star::uno::RuntimeException ); - virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentProviderInfo > SAL_CALL queryContentProviders() + virtual com::sun::star::uno::Sequence< + com::sun::star::ucb::ContentProviderInfo > SAL_CALL + queryContentProviders() throw( com::sun::star::uno::RuntimeException ); - virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > SAL_CALL queryContentProvider( const rtl::OUString& Scheme ) + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProvider > SAL_CALL + queryContentProvider( const rtl::OUString& Scheme ) throw( com::sun::star::uno::RuntimeException ); // XContentProvider - virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL queryContent( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier ) - throw( com::sun::star::ucb::IllegalIdentifierException, com::sun::star::uno::RuntimeException ); - virtual sal_Int32 SAL_CALL compareContentIds( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Id1, const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Id2 ) + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContent > SAL_CALL + queryContent( const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier >& Identifier ) + throw( com::sun::star::ucb::IllegalIdentifierException, + com::sun::star::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL + compareContentIds( const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier >& Id1, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier >& Id2 ) throw( com::sun::star::uno::RuntimeException ); // XContentIdentifierFactory - virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL createContentIdentifier( const rtl::OUString& ContentId ) + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier > SAL_CALL + createContentIdentifier( const rtl::OUString& ContentId ) throw( com::sun::star::uno::RuntimeException ); - // XContentCreator - virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL - queryCreatableContentsInfo() + // XCommandProcessor + virtual sal_Int32 SAL_CALL + createCommandIdentifier() throw( com::sun::star::uno::RuntimeException ); - virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL - createNewContent( const com::sun::star::ucb::ContentInfo& Info ) + virtual com::sun::star::uno::Any SAL_CALL + execute( const com::sun::star::ucb::Command& aCommand, + sal_Int32 CommandId, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& Environment ) + throw( com::sun::star::uno::Exception, + com::sun::star::ucb::CommandAbortedException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + abort( sal_Int32 CommandId ) throw( com::sun::star::uno::RuntimeException ); private: com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > queryContentProvider( const rtl::OUString& Scheme, sal_Bool bResolved ); - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > + getCommandInfo(); + + void + globalTransfer( + const com::sun::star::ucb::GlobalTransferCommandArgument & rArg, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& xEnv ) + throw( com::sun::star::uno::Exception ); + + com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > m_xSMgr; ProviderMap_Impl m_aProviders; osl::Mutex m_aMutex; cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; oslInterlockedCount m_nInitCount; //@@@ see initialize() method + sal_Int32 m_nCommandId; }; #endif /* !_UCB_HXX */ |