diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-17 09:41:52 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-10-31 12:03:29 +0100 |
commit | 75bc673b60d3eb40713868ce3d1b4f62dd6e1208 (patch) | |
tree | d377d1454c0dde448869a7c581c011862d3b555e /ucb/source | |
parent | 4cc2571e49de162f52ac9ec171f98732bb256517 (diff) |
Travelled MIME type through UCB for CMIS UCP to use it when creating documents
Change-Id: Id067932355607d3d60994862201b531f9844506d
Diffstat (limited to 'ucb/source')
-rw-r--r-- | ucb/source/core/ucb.cxx | 29 | ||||
-rw-r--r-- | ucb/source/core/ucb.hxx | 4 | ||||
-rw-r--r-- | ucb/source/core/ucbcmds.cxx | 38 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.cxx | 22 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.hxx | 3 |
5 files changed, 60 insertions, 36 deletions
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index e844b87fdc08..568f530cb2d3 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -26,7 +26,7 @@ #include <osl/diagnose.h> #include <cppuhelper/interfacecontainer.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp> +#include <com/sun/star/ucb/GlobalTransferCommandArgument2.hpp> #include <com/sun/star/ucb/XCommandInfo.hpp> #include <com/sun/star/ucb/XContentProvider.hpp> #include <com/sun/star/ucb/XContentProviderSupplier.hpp> @@ -654,16 +654,27 @@ Any SAL_CALL UniversalContentBroker::execute( // globalTransfer ////////////////////////////////////////////////////////////////// - GlobalTransferCommandArgument aTransferArg; + GlobalTransferCommandArgument2 aTransferArg; if ( !( aCommand.Argument >>= aTransferArg ) ) { - ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( - OUString( "Wrong argument type!" ), - static_cast< cppu::OWeakObject * >( this ), - -1 ) ), - Environment ); - // Unreachable + GlobalTransferCommandArgument aArg; + if ( !( aCommand.Argument >>= aArg ) ) + { + ucbhelper::cancelCommandExecution( + makeAny( IllegalArgumentException( + OUString( "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable + } + + // Copy infos into the new stucture + aTransferArg.Operation = aArg.Operation; + aTransferArg.SourceURL = aArg.SourceURL; + aTransferArg.TargetURL = aArg.TargetURL; + aTransferArg.NewTitle = aArg.NewTitle; + aTransferArg.NameClash = aArg.NameClash; } globalTransfer( aTransferArg, Environment ); diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx index 8cd61e413f0a..9de5839aa08e 100644 --- a/ucb/source/core/ucb.hxx +++ b/ucb/source/core/ucb.hxx @@ -49,7 +49,7 @@ namespace cppu { class OInterfaceContainerHelper; } namespace com { namespace sun { namespace star { namespace ucb { class XCommandInfo; - struct GlobalTransferCommandArgument; + struct GlobalTransferCommandArgument2; } } } } class UniversalContentBroker : @@ -176,7 +176,7 @@ private: void globalTransfer( - const com::sun::star::ucb::GlobalTransferCommandArgument & rArg, + const com::sun::star::ucb::GlobalTransferCommandArgument2 & rArg, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( com::sun::star::uno::Exception ); diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx index 62635e4f3a86..975b53fc8bd0 100644 --- a/ucb/source/core/ucbcmds.cxx +++ b/ucb/source/core/ucbcmds.cxx @@ -43,14 +43,14 @@ #include <com/sun/star/ucb/CommandEnvironment.hpp> #include <com/sun/star/ucb/CommandFailedException.hpp> #include <com/sun/star/ucb/ContentInfoAttribute.hpp> -#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> +#include <com/sun/star/ucb/GlobalTransferCommandArgument2.hpp> +#include <com/sun/star/ucb/InsertCommandArgument2.hpp> #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> #include <com/sun/star/ucb/NameClash.hpp> #include <com/sun/star/ucb/NameClashException.hpp> #include <com/sun/star/ucb/OpenCommandArgument2.hpp> #include <com/sun/star/ucb/OpenMode.hpp> -#include <com/sun/star/ucb/TransferInfo.hpp> +#include <com/sun/star/ucb/TransferInfo2.hpp> #include <com/sun/star/ucb/UnsupportedNameClashException.hpp> #include <com/sun/star/ucb/XCommandInfo.hpp> #include <com/sun/star/ucb/XContentAccess.hpp> @@ -80,14 +80,14 @@ struct TransferCommandContext uno::Reference< ucb::XCommandProcessor > xProcessor; uno::Reference< ucb::XCommandEnvironment > xEnv; uno::Reference< ucb::XCommandEnvironment > xOrigEnv; - ucb::GlobalTransferCommandArgument aArg; + ucb::GlobalTransferCommandArgument2 aArg; TransferCommandContext( const uno::Reference< lang::XMultiServiceFactory > & rxSMgr, const uno::Reference< ucb::XCommandProcessor > & rxProcessor, const uno::Reference< ucb::XCommandEnvironment > & rxEnv, const uno::Reference< ucb::XCommandEnvironment > & rxOrigEnv, - const ucb::GlobalTransferCommandArgument & rArg ) + const ucb::GlobalTransferCommandArgument2 & rArg ) : xSMgr( rxSMgr ), xProcessor( rxProcessor ), xEnv( rxEnv ), xOrigEnv( rxOrigEnv ), aArg( rArg ) {} }; @@ -1171,7 +1171,7 @@ void handleNameClashRename( } } - ucb::InsertCommandArgument aArg; + ucb::InsertCommandArgument2 aArg; aArg.Data = xInputStream; aArg.ReplaceExisting = sal_False; @@ -1354,8 +1354,9 @@ void globalTransfer_( // ////////////////////////////////////////////////////////////////////// - ucb::InsertCommandArgument aArg; + ucb::InsertCommandArgument2 aArg; aArg.Data = xInputStream; + aArg.MimeType = rContext.aArg.MimeType; switch ( rContext.aArg.NameClash ) { @@ -1599,13 +1600,14 @@ void globalTransfer_( if ( xResultSet->first() ) { - ucb::GlobalTransferCommandArgument aTransArg( - rContext.aArg.Operation, // Operation + ucb::GlobalTransferCommandArgument2 aTransArg( + rContext.aArg.Operation, rtl::OUString(), // SourceURL; filled later xNew->getIdentifier() ->getContentIdentifier(), // TargetURL rtl::OUString(), // NewTitle; - rContext.aArg.NameClash ); // NameClash + rContext.aArg.NameClash, + rContext.aArg.MimeType ); TransferCommandContext aSubCtx( rContext.xSMgr, @@ -1685,7 +1687,7 @@ UniversalContentBroker::getCommandInfo() //========================================================================= void UniversalContentBroker::globalTransfer( - const ucb::GlobalTransferCommandArgument & rArg, + const ucb::GlobalTransferCommandArgument2 & rArg, const uno::Reference< ucb::XCommandEnvironment > & xEnv ) throw( uno::Exception ) { @@ -1764,12 +1766,13 @@ void UniversalContentBroker::globalTransfer( // Unreachable } - ucb::TransferInfo aTransferArg( + ucb::TransferInfo2 aTransferArg( ( rArg.Operation == ucb::TransferCommandOperation_MOVE ), // MoveData - rArg.SourceURL, // SourceURL - rArg.NewTitle, // NewTitle - rArg.NameClash ); // NameClash + rArg.SourceURL, + rArg.NewTitle, + rArg.NameClash, + rArg.MimeType ); bool bRetry; do @@ -1808,11 +1811,12 @@ void UniversalContentBroker::globalTransfer( // NameClash::ERROR. try { - ucb::TransferInfo aTransferArg1( + ucb::TransferInfo2 aTransferArg1( aTransferArg.MoveData, aTransferArg.SourceURL, aTransferArg.NewTitle, - ucb::NameClash::ERROR ); + ucb::NameClash::ERROR, + aTransferArg.MimeType ); ucb::Command aCommand1( rtl::OUString("transfer"), diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index adf9eecd83d5..a2d8f4a2eb41 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -38,7 +38,7 @@ #include <com/sun/star/task/InteractionClassification.hpp> #include <com/sun/star/ucb/ContentInfo.hpp> #include <com/sun/star/ucb/ContentInfoAttribute.hpp> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> +#include <com/sun/star/ucb/InsertCommandArgument2.hpp> #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> #include <com/sun/star/ucb/MissingInputStreamException.hpp> @@ -668,7 +668,8 @@ namespace cmis } void Content::insert( const uno::Reference< io::XInputStream > & xInputStream, - sal_Bool bReplaceExisting, const uno::Reference< ucb::XCommandEnvironment >& xEnv ) + sal_Bool bReplaceExisting, const rtl::OUString& rMimeType, + const uno::Reference< ucb::XCommandEnvironment >& xEnv ) throw( uno::Exception ) { if ( !xInputStream.is() ) @@ -740,7 +741,7 @@ namespace cmis boost::shared_ptr< ostream > pOut( new ostringstream ( ios_base::binary | ios_base::in | ios_base::out ) ); uno::Reference < io::XOutputStream > xOutput = new ucbhelper::StdOutputStream( pOut ); copyData( xInputStream, xOutput ); - document->setContentStream( pOut, sMime, string( ), bReplaceExisting ); + document->setContentStream( pOut, sMime, OUSTR_TO_STDSTR( rMimeType ), bReplaceExisting ); } } else @@ -759,7 +760,7 @@ namespace cmis boost::shared_ptr< ostream > pOut( new ostringstream ( ios_base::binary | ios_base::in | ios_base::out ) ); uno::Reference < io::XOutputStream > xOutput = new ucbhelper::StdOutputStream( pOut ); copyData( xInputStream, xOutput ); - pFolder->createDocument( m_pObjectProps, pOut, string(), string() ); + pFolder->createDocument( m_pObjectProps, pOut, OUSTR_TO_STDSTR( rMimeType ), string() ); sNewPath = STD_TO_OUSTR( newPath ); } } @@ -1005,7 +1006,7 @@ namespace cmis -1, getCppuBooleanType() ), ucb::CommandInfo ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), - -1, getCppuType( static_cast<ucb::InsertCommandArgument * >( 0 ) ) ), + -1, getCppuType( static_cast<ucb::InsertCommandArgument2 * >( 0 ) ) ), ucb::CommandInfo ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), -1, getCppuType( static_cast<ucb::OpenCommandArgument2 * >( 0 ) ) ), @@ -1166,10 +1167,17 @@ namespace cmis } else if ( aCommand.Name == "insert" ) { - ucb::InsertCommandArgument arg; + ucb::InsertCommandArgument2 arg; if ( !( aCommand.Argument >>= arg ) ) + { + ucb::InsertCommandArgument insertArg; + if ( !( aCommand.Argument >>= insertArg ) ) ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv ); - insert( arg.Data, arg.ReplaceExisting, xEnv ); + + arg.Data = insertArg.Data; + arg.ReplaceExisting = insertArg.ReplaceExisting; + } + insert( arg.Data, arg.ReplaceExisting, arg.MimeType, xEnv ); } else if ( aCommand.Name == "delete" ) { diff --git a/ucb/source/ucp/cmis/cmis_content.hxx b/ucb/source/ucp/cmis/cmis_content.hxx index db98e3ee577a..8790834ed0cd 100644 --- a/ucb/source/ucp/cmis/cmis_content.hxx +++ b/ucb/source/ucp/cmis/cmis_content.hxx @@ -113,7 +113,8 @@ private: throw( com::sun::star::uno::Exception ); void insert( const com::sun::star::uno::Reference< com::sun::star::io::XInputStream > & xInputStream, - sal_Bool bReplaceExisting, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) + sal_Bool bReplaceExisting, const ::rtl::OUString & rMimeType, + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( com::sun::star::uno::Exception ); void destroy( ) throw( com::sun::star::uno::Exception ); |