[Libreoffice-commits] core.git: fpicker/source ucb/source

Giuseppe Castagno giuseppe.castagno at acca-esse.eu
Tue Feb 9 07:50:03 UTC 2016


 fpicker/source/office/RemoteFilesDialog.cxx  |   26 +++++++++++++++++++++++---
 ucb/source/ucp/webdav-neon/webdavcontent.cxx |   26 +++++---------------------
 2 files changed, 28 insertions(+), 24 deletions(-)

New commits:
commit f12e483589888f87843026ceff5ae3c1e615ca02
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date:   Mon Feb 1 16:04:49 2016 +0100

    Fix tdf#97500 Reinstate missing file error dialog on WebDAV
    
    Bug introduced with my fix to tdf#96669 in commit
    5fc2910fc872bbd1184aaab7c842dff593d2449b.
    
    Reverted previous fix and write a new version in fpicker instead.
    
    On WebDAV better check if the stream opens first, then check
    IsDocument property, because it may be a folder name.
    
    Change-Id: I72ce728329e4194080db6fa4cc4d98fecf7672e9
    Reviewed-on: https://gerrit.libreoffice.org/22214
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>

diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index e4b0e1d..c497eca 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 #include "RemoteFilesDialog.hxx"
+#include <comphelper/stillreadwriteinteraction.hxx>
 
 class FileViewContainer : public vcl::Window
 {
@@ -1416,10 +1417,29 @@ bool RemoteFilesDialog::ContentIsDocument( const OUString& rURL )
     {
         Reference< XInteractionHandler > xInteractionHandler(
                         InteractionHandler::createWithParent( m_xContext, nullptr ), UNO_QUERY_THROW );
-        Reference< XCommandEnvironment > xEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
-        ::ucbhelper::Content aContent( rURL, xEnv, m_xContext );
+        //check if WebDAV or not
+        if ( !INetURLObject( rURL ).isAnyKnownWebDAVScheme() )
+        {
+                // no webdav, use the interaction handler as is
+                Reference< XCommandEnvironment > xEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
+                ::ucbhelper::Content aContent( rURL, xEnv, m_xContext );
 
-        return aContent.isDocument();
+                return aContent.isDocument();
+        }
+        else
+        {
+            // It's a webdav URL, so use the same open sequence as in normal open process.
+            // Let's use a comphelper::StillReadWriteInteraction to trap errors here without showing the user.
+            // This sequence will result in an exception if the target URL resource is not present
+            comphelper::StillReadWriteInteraction* pInteraction = new comphelper::StillReadWriteInteraction(xInteractionHandler,xInteractionHandler);
+            css::uno::Reference< css::task::XInteractionHandler > xInteraction(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY);
+
+            Reference< XCommandEnvironment > xEnv = new ::ucbhelper::CommandEnvironment( xInteraction, Reference< XProgressHandler >() );
+            ::ucbhelper::Content aContent( rURL, xEnv, m_xContext );
+
+            aContent.openStream();
+            return aContent.isDocument();
+        }
     }
     catch( const Exception& )
     {
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 4924e02..b68dc64 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -865,7 +865,6 @@ void Content::addProperty( const ucb::PropertyCommandArgument& aCmdArg,
                     switch ( eType )
                     {
                     case UNKNOWN:
-                    case NOT_FOUND:
                     case DAV:
                         throw lang::IllegalArgumentException();
 
@@ -954,7 +953,6 @@ void Content::removeProperty( const OUString& Name,
                     switch ( eType )
                     {
                         case UNKNOWN:
-                        case NOT_FOUND:
                         case DAV:
                             throw beans::UnknownPropertyException();
 
@@ -1444,7 +1442,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
         NeonUri aUri( xResAccess->getURL() );
         aUnescapedTitle = aUri.GetPathBaseNameUnescaped();
 
-        if ( eType == UNKNOWN || eType == NOT_FOUND )
+        if ( eType == UNKNOWN )
         {
             xProps.reset( new ContentProperties( aUnescapedTitle ) );
         }
@@ -1475,20 +1473,10 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
                 "IsFolder",
                 uno::makeAny( false ),
                 true );
-            if ( eType == NOT_FOUND )
-            {
-                xProps->addProperty(
-                "IsDocument",
-                uno::makeAny( false ),
-                true );
-            }
-            else
-            {
-                xProps->addProperty(
+            xProps->addProperty(
                 "IsDocument",
                 uno::makeAny( true ),
                 true );
-            }
         }
     }
     else
@@ -2912,7 +2900,7 @@ Content::ResourceType Content::resourceTypeForLocks(
         }
     }
     osl::MutexGuard g(m_aMutex);
-    if ( m_eResourceTypeForLocks == UNKNOWN || m_eResourceTypeForLocks == NOT_FOUND )
+    if (m_eResourceTypeForLocks == UNKNOWN)
     {
         m_eResourceTypeForLocks = eResourceTypeForLocks;
     }
@@ -3450,7 +3438,7 @@ Content::ResourceType Content::getResourceType(
 {
     {
         osl::MutexGuard g(m_aMutex);
-        if ( m_eResourceType != UNKNOWN && m_eResourceType != NOT_FOUND ) {
+        if (m_eResourceType != UNKNOWN) {
             return m_eResourceType;
         }
     }
@@ -3499,10 +3487,6 @@ Content::ResourceType Content::getResourceType(
         {
             rResAccess->resetUri();
 
-            if ( e.getStatus() == SC_NOT_FOUND )
-            {
-                eResourceType = NOT_FOUND;
-            }
             if ( e.getStatus() == SC_METHOD_NOT_ALLOWED )
             {
                 // Status SC_METHOD_NOT_ALLOWED is a safe indicator that the
@@ -3526,7 +3510,7 @@ Content::ResourceType Content::getResourceType(
     }
 
     osl::MutexGuard g(m_aMutex);
-    if ( m_eResourceType == UNKNOWN || m_eResourceType == NOT_FOUND ) {
+    if (m_eResourceType == UNKNOWN) {
         m_eResourceType = eResourceType;
     } else {
         SAL_WARN_IF(


More information about the Libreoffice-commits mailing list