fpicker/source/office/RemoteFilesDialog.cxx |   55 +---------------------------
 fpicker/source/office/RemoteFilesDialog.hxx |    2 -
 2 files changed, 4 insertions(+), 53 deletions(-)

New commits:
commit 67fa088be7db1df661188ef4bab490a76fb06b85
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Oct 18 14:18:03 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Oct 18 17:21:21 2021 +0200

    tdf#145169 for IsDocument/IsFolder I think we want no interaction
    
    rather than installing something to sometimes disable interaction
    I think we just want to not have any interaction here at all
    
    Change-Id: Ic775f0cd88f796db873d2980bb40043caac498bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123750
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/fpicker/source/office/RemoteFilesDialog.cxx 
b/fpicker/source/office/RemoteFilesDialog.cxx
index 2d1c4c961119..9c12a1efc25b 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -22,6 +22,7 @@
 #include <svtools/PlaceEditDialog.hxx>
 #include <tools/debug.hxx>
 #include <ucbhelper/commandenvironment.hxx>
+#include <svl/fstathelper.hxx>
 #include <vcl/errinf.hxx>
 #include <officecfg/Office/Common.hxx>
 
@@ -1142,62 +1143,12 @@ std::vector<OUString> RemoteFilesDialog::GetPathList() 
const
 
 bool RemoteFilesDialog::ContentIsFolder( const OUString& rURL )
 {
-    try
-    {
-        Reference< XInteractionHandler > xInteractionHandler(
-                        InteractionHandler::createWithParent( m_xContext, 
nullptr ), UNO_QUERY_THROW );
-        INetURLObject aURLObject(rURL);
-        if (aURLObject.isAnyKnownWebDAVScheme() || aURLObject.GetProtocol() == 
INetProtocol::Sftp)
-            xInteractionHandler.set(new 
comphelper::StillReadWriteInteraction(xInteractionHandler, 
xInteractionHandler));
-        Reference< XCommandEnvironment > xEnv = new 
::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< 
XProgressHandler >() );
-        ::ucbhelper::Content aContent( rURL, xEnv, m_xContext );
-
-        return aContent.isFolder();
-    }
-    catch( const Exception& )
-    {
-        // a content doesn't exist
-    }
-
-    return false;
+    return FStatHelper::IsFolder(rURL);
 }
 
 bool RemoteFilesDialog::ContentIsDocument( const OUString& rURL )
 {
-    try
-    {
-        Reference< XInteractionHandler > xInteractionHandler(
-                        InteractionHandler::createWithParent( m_xContext, 
nullptr ), UNO_QUERY_THROW );
-        //check if WebDAV or not
-        INetURLObject aURLObject(rURL);
-        if (!aURLObject.isAnyKnownWebDAVScheme() && aURLObject.GetProtocol() 
!= INetProtocol::Sftp)
-        {
-                // 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();
-        }
-        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
-            rtl::Reference<comphelper::StillReadWriteInteraction> pInteraction 
= new 
comphelper::StillReadWriteInteraction(xInteractionHandler,xInteractionHandler);
-
-            Reference< XCommandEnvironment > xEnv = new 
::ucbhelper::CommandEnvironment( pInteraction, Reference< XProgressHandler >() 
);
-            ::ucbhelper::Content aContent( rURL, xEnv, m_xContext );
-
-            aContent.openStream();
-            return aContent.isDocument();
-        }
-    }
-    catch( const Exception& )
-    {
-        // a content doesn't exist
-    }
-
-    return false;
+    return FStatHelper::IsDocument(rURL);
 }
 
 sal_Int32 RemoteFilesDialog::getAvailableWidth()
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx 
b/fpicker/source/office/RemoteFilesDialog.hxx
index 55cfa2870d59..6ff5ae747212 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -68,7 +68,7 @@ public:
     virtual const OUString& GetPath() override;
     virtual std::vector<OUString> GetPathList() const override;
     virtual bool ContentIsFolder( const OUString& rURL ) override;
-    bool ContentIsDocument( const OUString& rURL );
+    static bool ContentIsDocument(const OUString& rURL);
 
     virtual OUString getCurrentFileText() const override;
     virtual void setCurrentFileText( const OUString& rText, bool bSelectAll = 
false ) override;

Reply via email to