Blame SOURCES/openoffice.org-3.1.0.ooo101274.opening-a-directory.patch

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