summaryrefslogtreecommitdiff
path: root/ucbhelper/source
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2001-02-07 07:01:44 +0000
committerKai Sommerfeld <kso@openoffice.org>2001-02-07 07:01:44 +0000
commitef6a613ae4bc58fd83eacac4cacbdd0504c334e7 (patch)
treed665c53caf560330feed72f512360b33b61713f3 /ucbhelper/source
parent335863620e5781b693f4cdf7a19b9b06c488de09 (diff)
#83045# - Added support for "globalTransfer".
Diffstat (limited to 'ucbhelper/source')
-rw-r--r--ucbhelper/source/client/content.cxx110
-rw-r--r--ucbhelper/source/client/contentbroker.cxx24
2 files changed, 129 insertions, 5 deletions
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
index 5dde43cbd808..0cc4826f0787 100644
--- a/ucbhelper/source/client/content.cxx
+++ b/ucbhelper/source/client/content.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: content.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: kso $ $Date: 2001-02-05 15:54:42 $
+ * last change: $Author: kso $ $Date: 2001-02-07 08:01:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,6 +63,8 @@
TODO
**************************************************************************
+ - Register content-event-listener to handle EXCHANGED and DELETED events.
+
*************************************************************************/
#ifndef _VOS_MUTEX_HXX_
@@ -96,6 +98,12 @@
#ifndef _COM_SUN_STAR_UCB_INSERTCOMMANDARGUMENT_HPP_
#include <com/sun/star/ucb/InsertCommandArgument.hpp>
#endif
+#ifndef _COM_SUN_STAR_UCB_GLOBALTRANSFERCOMMANDARGUMENT_HPP_
+#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_NAMECLASH_HPP_
+#include <com/sun/star/ucb/NameClash.hpp>
+#endif
#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
#include <com/sun/star/ucb/OpenMode.hpp>
#endif
@@ -162,6 +170,7 @@ namespace ucb
class Content_Impl : public vos::OReference
{
+ OUString m_aURL;
Reference< XMultiServiceFactory > m_xSMgr;
Reference< XContent > m_xContent;
Reference< XCommandProcessor > m_xCommandProcessor;
@@ -177,13 +186,16 @@ public:
virtual ~Content_Impl();
+ const OUString& getURL() const { return m_aURL; }
Reference< XContent > getContent() const { return m_xContent; }
Reference< XCommandProcessor > getCommandProcessor();
sal_Int32 getCommandId();
Any executeCommand( const Command& rCommand );
void abortCommand();
- Reference< XCommandEnvironment > getEnvironment() const { return m_xEnv; }
+ inline const Reference< XCommandEnvironment >& getEnvironment() const;
+ inline void setEnvironment(
+ const Reference< XCommandEnvironment >& xNewEnv );
};
//=========================================================================
@@ -196,6 +208,26 @@ inline Content_Impl::Content_Impl(
m_xEnv( rEnv ),
m_aCommandId( 0 )
{
+ if ( m_xContent.is() )
+ {
+ // @@@ register content-event-listener
+ m_aURL = m_xContent->getIdentifier()->getContentIdentifier();
+ }
+}
+
+//=========================================================================
+inline const Reference< XCommandEnvironment >&
+ Content_Impl::getEnvironment() const
+{
+ return m_xEnv;
+}
+
+//=========================================================================
+inline void Content_Impl::setEnvironment(
+ const Reference< XCommandEnvironment >& xNewEnv )
+{
+ vos::OGuard aGuard( m_aMutex );
+ m_xEnv = xNewEnv;
}
//=========================================================================
@@ -468,6 +500,25 @@ Reference< XContent > Content::get() const
}
//=========================================================================
+const OUString& Content::getURL() const
+{
+ return m_xImpl->getURL();
+}
+
+//=========================================================================
+const Reference< XCommandEnvironment >& Content::getCommandEnvironment() const
+{
+ return m_xImpl->getEnvironment();
+}
+
+//=========================================================================
+void Content::setCommandEnvironment(
+ const Reference< XCommandEnvironment >& xNewEnv )
+{
+ m_xImpl->setEnvironment( xNewEnv );
+}
+
+//=========================================================================
Reference< XCommandInfo > Content::getCommands()
throw( CommandAbortedException, RuntimeException, Exception )
{
@@ -1166,6 +1217,59 @@ sal_Bool Content::insertNewContent( const OUString& rContentType,
}
//=========================================================================
+sal_Bool Content::insertNewContent( const Content& rSourceContent,
+ InsertOperation eOperation,
+ Content& rNewContent )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ ucb::ContentBroker* pBroker = ucb::ContentBroker::get();
+ if ( !pBroker )
+ throw CommandAbortedException();
+
+ Reference< XCommandProcessor > xCmdProc(
+ pBroker->getCommandProcessorInterface() );
+ if ( !xCmdProc.is() )
+ throw CommandAbortedException();
+
+ // Execute command "globalTransfer" at UCB.
+
+ TransferCommandOperation eTransOp;
+ switch ( eOperation )
+ {
+ case InsertOperation_COPY:
+ eTransOp = TransferCommandOperation_COPY;
+ break;
+
+ case InsertOperation_MOVE:
+ eTransOp = TransferCommandOperation_MOVE;
+ break;
+
+ case InsertOperation_LINK:
+ eTransOp = TransferCommandOperation_LINK;
+ break;
+
+ default:
+ VOS_ENSURE( sal_False,
+ "Content::insertNewContent - Unknown operation!" );
+ throw CommandAbortedException();
+ }
+
+ GlobalTransferCommandArgument aTransferArg(
+ eTransOp,
+ rSourceContent.getURL(), // SourceURL
+ getURL(), // TargetURL,
+ OUString(), // NewTitle
+ NameClash::ERROR );
+ Command aCommand;
+ aCommand.Name = OUString::createFromAscii( "globalTransfer" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aTransferArg;
+
+ xCmdProc->execute( aCommand, 0, m_xImpl->getEnvironment() );
+ return sal_True;
+}
+
+//=========================================================================
sal_Bool Content::isFolder()
throw( CommandAbortedException, RuntimeException, Exception )
{
diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx
index d6ad6c9f1a18..3b380c881d4b 100644
--- a/ucbhelper/source/client/contentbroker.cxx
+++ b/ucbhelper/source/client/contentbroker.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: contentbroker.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 17:03:37 $
+ * last change: $Author: kso $ $Date: 2001-02-07 08:01:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,6 +80,9 @@
#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDERMANAGER_HPP_
#include <com/sun/star/ucb/XContentProviderManager.hpp>
#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
#ifndef _VOS_MUTEX_HXX_
#include <vos/mutex.hxx>
@@ -114,6 +117,7 @@ class ContentBroker_Impl
Reference< XContentIdentifierFactory > m_xIdFac;
Reference< XContentProvider > m_xProvider;
Reference< XContentProviderManager > m_xProviderMgr;
+ Reference< XCommandProcessor > m_xCommandProc;
Sequence< Any > m_aArguments;
vos::OMutex m_aMutex;
sal_Bool m_bInitDone;
@@ -141,6 +145,9 @@ public:
const Reference< XContentProviderManager >& getProviderManager() const
{ init(); return m_xProviderMgr; }
+
+ const Reference< XCommandProcessor >& getCommandProcessor() const
+ { init(); return m_xCommandProc; }
};
//=========================================================================
@@ -195,6 +202,13 @@ Reference< XContentProviderManager >
}
//=========================================================================
+Reference< XCommandProcessor >
+ ContentBroker::getCommandProcessorInterface() const
+{
+ return m_pImpl->getCommandProcessor();
+}
+
+//=========================================================================
// static
sal_Bool ContentBroker::initialize(
const Reference< XMultiServiceFactory >& rSMgr,
@@ -291,6 +305,12 @@ void ContentBroker_Impl::init()
VOS_ENSURE( m_xProviderMgr.is(),
"UCB without XContentProviderManager!" );
+
+ m_xCommandProc
+ = Reference< XCommandProcessor >( xIfc, UNO_QUERY );
+
+ VOS_ENSURE( m_xCommandProc.is(),
+ "UCB without XCommandProcessor!" );
}
}
}