ce85ecb
From 1be2e01e592466aec2e60fbf1af528cfab1572db Mon Sep 17 00:00:00 2001
d8184f2
From: David Tardon <dtardon@redhat.com>
d8184f2
Date: Thu, 1 Dec 2011 14:02:07 +0100
ce85ecb
Subject: [PATCH] #i101274 a directory on command line is silently ignored
d8184f2
d8184f2
---
ce85ecb
 .../source/misc/stillreadwriteinteraction.cxx      |  1 +
ce85ecb
 ucbhelper/source/client/content.cxx                | 75 ++++++++++++++++++++++
ce85ecb
 2 files changed, 76 insertions(+)
d8184f2
d8184f2
diff --git a/comphelper/source/misc/stillreadwriteinteraction.cxx b/comphelper/source/misc/stillreadwriteinteraction.cxx
ce85ecb
index b3dd6e8..d0f5738 100644
d8184f2
--- a/comphelper/source/misc/stillreadwriteinteraction.cxx
d8184f2
+++ b/comphelper/source/misc/stillreadwriteinteraction.cxx
ce85ecb
@@ -87,6 +87,7 @@ ucbhelper::InterceptedInteraction::EInterceptionState StillReadWriteInteraction:
d8184f2
             bAbort = (
d8184f2
                 (exIO.Code == css::ucb::IOErrorCode_ACCESS_DENIED     )
d8184f2
                 || (exIO.Code == css::ucb::IOErrorCode_LOCKING_VIOLATION )
d8184f2
+				|| (exIO.Code == css::ucb::IOErrorCode_NO_FILE )
d8184f2
                 || (exIO.Code == css::ucb::IOErrorCode_NOT_EXISTING )
d8184f2
 #ifdef MACOSX
d8184f2
                 // this is a workaround for MAC, on this platform if the file is locked
d8184f2
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
ce85ecb
index 95e589f..d7fc181 100644
d8184f2
--- a/ucbhelper/source/client/content.cxx
d8184f2
+++ b/ucbhelper/source/client/content.cxx
ce85ecb
@@ -27,6 +27,7 @@
8076325
 #include <cppuhelper/weak.hxx>
8076325
 
8076325
 #include <cppuhelper/implbase1.hxx>
8076325
+#include <com/sun/star/beans/PropertyValue.hpp>
a2f244f
 #include <com/sun/star/ucb/CheckinArgument.hpp>
8076325
 #include <com/sun/star/ucb/ContentCreationError.hpp>
8076325
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
ce85ecb
@@ -37,6 +38,8 @@
8076325
 #include <com/sun/star/ucb/ContentAction.hpp>
8076325
 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
8076325
 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
8076325
+#include <com/sun/star/ucb/IOErrorCode.hpp>
8076325
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
a2f244f
 #include <com/sun/star/ucb/GlobalTransferCommandArgument2.hpp>
8076325
 #include <com/sun/star/ucb/NameClash.hpp>
8076325
 #include <com/sun/star/ucb/OpenMode.hpp>
ce85ecb
@@ -56,12 +59,18 @@
8076325
 #include <com/sun/star/sdbc/XRow.hpp>
8076325
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
8076325
 #include <com/sun/star/beans/UnknownPropertyException.hpp>
8076325
+#include <com/sun/star/task/XInteractionRequest.hpp>
8076325
+
8076325
 #include <ucbhelper/macros.hxx>
8076325
 #include <ucbhelper/content.hxx>
a2f244f
 #include <ucbhelper/activedatasink.hxx>
8076325
 #include <ucbhelper/activedatastreamer.hxx>
8076325
 #include <ucbhelper/interactionrequest.hxx>
8076325
 #include <ucbhelper/cancelcommandexecution.hxx>
8076325
+#include <ucbhelper/fileidentifierconverter.hxx>
8076325
+#include <ucbhelper/simpleinteractionrequest.hxx>
8076325
+
8076325
+#include <memory>
8076325
 
8076325
 using namespace com::sun::star::container;
8076325
 using namespace com::sun::star::beans;
ce85ecb
@@ -283,6 +292,54 @@ static Reference< XContent > getContent(
8076325
     return Reference< XContent >();
8076325
 }
8076325
 
8076325
+namespace
8076325
+{
8076325
+
8076325
+void
8076325
+lcl_displayMessage(
ce85ecb
+        const Reference<XComponentContext>& rContext,
8076325
+        const Reference<XCommandEnvironment>& rEnvironment,
8076325
+        const rtl::OUString& rUri)
8076325
+{
8076325
+    // Create exception
ce85ecb
+    const Reference<XUniversalContentBroker> xBroker(UniversalContentBroker::create(rContext));
8076325
+    const PropertyValue aUriProperty(
8076325
+            rtl::OUString::createFromAscii("Uri"),
8076325
+            -1,
ce85ecb
+            makeAny(getSystemPathFromFileURL(xBroker, rUri)),
8076325
+            PropertyState_DIRECT_VALUE)
8076325
+        ;
8076325
+    Sequence<Any> lArguments(1);
8076325
+    lArguments[0] <<= aUriProperty;
8076325
+    const InteractiveAugmentedIOException xError(
8076325
+            rtl::OUString(),
8076325
+            0,
8076325
+            InteractionClassification_ERROR,
8076325
+            IOErrorCode_NO_FILE,
8076325
+            lArguments)
8076325
+        ;
8076325
+
8076325
+    // Create interaction request
8076325
+    std::auto_ptr<ucbhelper::SimpleInteractionRequest> aRequest(
8076325
+            new ucbhelper::SimpleInteractionRequest(makeAny(xError), CONTINUATION_APPROVE));
8076325
+    {
8076325
+        Reference<XInteractionContinuation> xContinuation(
8076325
+                new ::ucbhelper::InteractionApprove(aRequest.get()));
8076325
+        Sequence<Reference<XInteractionContinuation> > lContinuations(1);
8076325
+        lContinuations[0].set(xContinuation);
8076325
+        aRequest->setContinuations(lContinuations);
8076325
+    }
8076325
+
8076325
+    Reference<XInteractionHandler> xInteraction(rEnvironment->getInteractionHandler());
8076325
+    if (xInteraction.is())
8076325
+    {
8076325
+        Reference<XInteractionRequest> xRequest(aRequest.release());
8076325
+        xInteraction->handle(xRequest);
8076325
+    }
8076325
+}
8076325
+    
8076325
+}
8076325
+
8076325
 //=========================================================================
8076325
 //=========================================================================
8076325
 //
ce85ecb
@@ -699,7 +756,10 @@ Reference< XInputStream > Content::openStream()
8076325
     throw( CommandAbortedException, RuntimeException, Exception )
8076325
 {
8076325
     if ( !isDocument() )
8076325
+    {
ce85ecb
+        lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL());
8076325
         return Reference< XInputStream >();
8076325
+    }
8076325
 
8076325
     Reference< XActiveDataSink > xSink = new ActiveDataSink;
8076325
 
ce85ecb
@@ -724,7 +784,10 @@ Reference< XInputStream > Content::openStreamNoLock()
8076325
     throw( CommandAbortedException, RuntimeException, Exception )
8076325
 {
8076325
     if ( !isDocument() )
8076325
+    {
ce85ecb
+        lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL());
8076325
         return Reference< XInputStream >();
8076325
+    }
8076325
 
8076325
     Reference< XActiveDataSink > xSink = new ActiveDataSink;
8076325
 
ce85ecb
@@ -749,7 +812,10 @@ Reference< XStream > Content::openWriteableStream()
8076325
     throw( CommandAbortedException, RuntimeException, Exception )
8076325
 {
8076325
     if ( !isDocument() )
8076325
+    {
ce85ecb
+        lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL());
8076325
         return Reference< XStream >();
8076325
+    }
8076325
 
8076325
     Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
8076325
 
ce85ecb
@@ -774,7 +840,10 @@ Reference< XStream > Content::openWriteableStreamNoLock()
8076325
     throw( CommandAbortedException, RuntimeException, Exception )
8076325
 {
8076325
     if ( !isDocument() )
8076325
+    {
ce85ecb
+        lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL());
8076325
         return Reference< XStream >();
8076325
+    }
8076325
 
8076325
     Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
8076325
 
ce85ecb
@@ -799,7 +868,10 @@ sal_Bool Content::openStream( const Reference< XActiveDataSink >& rSink )
8076325
     throw( CommandAbortedException, RuntimeException, Exception )
8076325
 {
8076325
     if ( !isDocument() )
8076325
+    {
ce85ecb
+        lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL());
8076325
         return sal_False;
8076325
+    }
8076325
 
8076325
     OpenCommandArgument2 aArg;
8076325
     aArg.Mode       = OpenMode::DOCUMENT;
ce85ecb
@@ -822,7 +894,10 @@ sal_Bool Content::openStream( const Reference< XOutputStream >& rStream )
8076325
     throw( CommandAbortedException, RuntimeException, Exception )
8076325
 {
8076325
     if ( !isDocument() )
8076325
+    {
ce85ecb
+        lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL());
8076325
         return sal_False;
8076325
+    }
8076325
 
8076325
     OpenCommandArgument2 aArg;
8076325
     aArg.Mode       = OpenMode::DOCUMENT;
d8184f2
-- 
ce85ecb
1.8.0
d8184f2