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

New commits:
commit e4ff5b1fbabb538356053383a3491e3e986d1164
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Mon Nov 22 16:38:29 2021 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Nov 23 12:07:03 2021 +0100

    tdf#145769 fpicker: RemoteFilesDialog: don't use FStatHelper
    
    FStatHelper doesn't use an XCommandEnvironment and is thus unsuitable
    for remote access as it can't even authenticate with the password
    container; it should only be used for local access.
    
    Due to this problem, the ContentIsDocument() would always return a
    hard-coded "true" value from the webdav UCP, causing a spurious dialog
    that an existing file would be overwritten in Save Remote.
    
    (regression from 67fa088be7db1df661188ef4bab490a76fb06b85)
    
    Change-Id: Ibe667f2012e261b84d4c69c84fdd499b7276e64b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125666
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/fpicker/source/office/RemoteFilesDialog.cxx 
b/fpicker/source/office/RemoteFilesDialog.cxx
index b7efa8071116..dd4d4d32195a 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -22,7 +22,7 @@
 #include <svtools/PlaceEditDialog.hxx>
 #include <tools/debug.hxx>
 #include <ucbhelper/commandenvironment.hxx>
-#include <svl/fstathelper.hxx>
+#include <unotools/ucbhelper.hxx>
 #include <vcl/errinf.hxx>
 #include <officecfg/Office/Common.hxx>
 
@@ -1140,12 +1140,32 @@ std::vector<OUString> RemoteFilesDialog::GetPathList() 
const
 
 bool RemoteFilesDialog::ContentIsFolder( const OUString& rURL )
 {
-    return FStatHelper::IsFolder(rURL);
+    try
+    {
+        ::ucbhelper::Content content(rURL,
+            ::utl::UCBContentHelper::getDefaultCommandEnvironment(),
+            m_xContext);
+        return content.isFolder();
+    }
+    catch (css::uno::Exception const&)
+    {
+        return false;
+    }
 }
 
 bool RemoteFilesDialog::ContentIsDocument( const OUString& rURL )
 {
-    return FStatHelper::IsDocument(rURL);
+    try
+    {
+        ::ucbhelper::Content content(rURL,
+            ::utl::UCBContentHelper::getDefaultCommandEnvironment(),
+            m_xContext);
+        return content.isDocument();
+    }
+    catch (css::uno::Exception const&)
+    {
+        return false;
+    }
 }
 
 sal_Int32 RemoteFilesDialog::getAvailableWidth()
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx 
b/fpicker/source/office/RemoteFilesDialog.hxx
index 93a8e363f5b4..3dfb4e1dc9aa 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;
-    static bool ContentIsDocument(const OUString& rURL);
+    bool ContentIsDocument(const OUString& rURL);
 
     virtual OUString getCurrentFileText() const override;
     virtual void setCurrentFileText( const OUString& rText, bool bSelectAll = 
false ) override;

Reply via email to