From 9834a43821ccf9feb4cee971057f3fc136b5add8 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 1 Dec 2011 14:02:07 +0100 Subject: [PATCH] #i101274 a directory on command line is silently ignored --- .../source/misc/stillreadwriteinteraction.cxx | 1 + ucbhelper/source/client/content.cxx | 75 ++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/comphelper/source/misc/stillreadwriteinteraction.cxx b/comphelper/source/misc/stillreadwriteinteraction.cxx index 10f1855..650b88f 100644 --- a/comphelper/source/misc/stillreadwriteinteraction.cxx +++ b/comphelper/source/misc/stillreadwriteinteraction.cxx @@ -85,6 +85,7 @@ ucbhelper::InterceptedInteraction::EInterceptionState StillReadWriteInteraction: bAbort = ( (exIO.Code == css::ucb::IOErrorCode_ACCESS_DENIED ) || (exIO.Code == css::ucb::IOErrorCode_LOCKING_VIOLATION ) + || (exIO.Code == css::ucb::IOErrorCode_NO_FILE ) || (exIO.Code == css::ucb::IOErrorCode_NOT_EXISTING ) #ifdef MACOSX // this is a workaround for MAC, on this platform if the file is locked diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx index c8ccd88..ac5920a 100644 --- a/ucbhelper/source/client/content.cxx +++ b/ucbhelper/source/client/content.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,8 @@ #include #include #include +#include +#include #include #include #include @@ -56,12 +59,18 @@ #include #include #include +#include + #include #include #include #include #include #include +#include +#include + +#include using namespace com::sun::star::container; using namespace com::sun::star::beans; @@ -304,6 +313,54 @@ static Reference< XContent > getContentNoThrow( return xContent; } +namespace +{ + +void +lcl_displayMessage( + const Reference& rContext, + const Reference& rEnvironment, + const rtl::OUString& rUri) +{ + // Create exception + const Reference xBroker(UniversalContentBroker::create(rContext)); + const PropertyValue aUriProperty( + rtl::OUString::createFromAscii("Uri"), + -1, + makeAny(getSystemPathFromFileURL(xBroker, rUri)), + PropertyState_DIRECT_VALUE) + ; + Sequence lArguments(1); + lArguments[0] <<= aUriProperty; + const InteractiveAugmentedIOException xError( + rtl::OUString(), + 0, + InteractionClassification_ERROR, + IOErrorCode_NO_FILE, + lArguments) + ; + + // Create interaction request + std::auto_ptr aRequest( + new ucbhelper::SimpleInteractionRequest(makeAny(xError), CONTINUATION_APPROVE)); + { + Reference xContinuation( + new ::ucbhelper::InteractionApprove(aRequest.get())); + Sequence > lContinuations(1); + lContinuations[0].set(xContinuation); + aRequest->setContinuations(lContinuations); + } + + Reference xInteraction(rEnvironment->getInteractionHandler()); + if (xInteraction.is()) + { + Reference xRequest(aRequest.release()); + xInteraction->handle(xRequest); + } +} + +} + @@ -718,7 +775,10 @@ Reference< XInputStream > Content::openStream() throw( CommandAbortedException, RuntimeException, Exception ) { if ( !isDocument() ) + { + lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL()); return Reference< XInputStream >(); + } Reference< XActiveDataSink > xSink = new ActiveDataSink; @@ -743,7 +803,10 @@ Reference< XInputStream > Content::openStreamNoLock() throw( CommandAbortedException, RuntimeException, Exception ) { if ( !isDocument() ) + { + lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL()); return Reference< XInputStream >(); + } Reference< XActiveDataSink > xSink = new ActiveDataSink; @@ -768,7 +831,10 @@ Reference< XStream > Content::openWriteableStream() throw( CommandAbortedException, RuntimeException, Exception ) { if ( !isDocument() ) + { + lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL()); return Reference< XStream >(); + } Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer; @@ -793,7 +859,10 @@ Reference< XStream > Content::openWriteableStreamNoLock() throw( CommandAbortedException, RuntimeException, Exception ) { if ( !isDocument() ) + { + lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL()); return Reference< XStream >(); + } Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer; @@ -818,7 +887,10 @@ bool Content::openStream( const Reference< XActiveDataSink >& rSink ) throw( CommandAbortedException, RuntimeException, Exception ) { if ( !isDocument() ) + { + lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL()); return false; + } OpenCommandArgument2 aArg; aArg.Mode = OpenMode::DOCUMENT; @@ -841,7 +913,10 @@ bool Content::openStream( const Reference< XOutputStream >& rStream ) throw( CommandAbortedException, RuntimeException, Exception ) { if ( !isDocument() ) + { + lcl_displayMessage(m_xImpl->getComponentContext(), m_xImpl->getEnvironment(), getURL()); return false; + } OpenCommandArgument2 aArg; aArg.Mode = OpenMode::DOCUMENT; -- 1.9.0