From e4ff5b1fbabb538356053383a3491e3e986d1164 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 22 Nov 2021 16:38:29 +0100 Subject: 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 Reviewed-by: Michael Stahl --- fpicker/source/office/RemoteFilesDialog.cxx | 26 +++++++++++++++++++++++--- fpicker/source/office/RemoteFilesDialog.hxx | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'fpicker') 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 #include #include -#include +#include #include #include @@ -1140,12 +1140,32 @@ std::vector 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 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; -- cgit