cui/source/dialogs/AdditionsDialog.cxx | 10 +++++++--- include/unotools/ucbstreamhelper.hxx | 11 ++++++++--- ucb/source/ucp/webdav-curl/webdavcontent.cxx | 13 +++++++++++++ unotools/source/ucbhelper/ucbstreamhelper.cxx | 19 ++++++++++++++++--- 4 files changed, 44 insertions(+), 9 deletions(-)
New commits: commit 2ad7d5cfb0288559921b0d9ccad0a23d95cde452 Author: Sarper Akdemir <sarper.akde...@allotropia.de> AuthorDate: Fri Jun 21 12:40:11 2024 +0200 Commit: Sarper Akdemir <sarper.akde...@allotropia.de> CommitDate: Fri Jun 28 12:06:25 2024 +0200 make additionsdialog show connection errors use non-scoped interaction handler instead of the scoped SimpleFileAccessInteraction so that errors will be handled with correct pop-up dialogs. Also throw the correct type of DAVException for USC_CONNECT_FAILED in Content::Open Change-Id: If2031dfa2796f91fad6866bc9608194c92658b96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169519 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx index 61bee50455b3..3f57676a13ec 100644 --- a/cui/source/dialogs/AdditionsDialog.cxx +++ b/cui/source/dialogs/AdditionsDialog.cxx @@ -71,11 +71,12 @@ using namespace ::com::sun::star::beans; namespace { // Gets the content of the given URL and returns as a standard string -std::string ucbGet(const OUString& rURL) +std::string ucbGet(const OUString& rURL, const css::uno::Reference<css::awt::XWindow>& xParentWin) { try { - auto const s = utl::UcbStreamHelper::CreateStream(rURL, StreamMode::STD_READ); + auto const s + = utl::UcbStreamHelper::CreateStream(rURL, StreamMode::STD_READ, xParentWin, false); if (!s) { SAL_WARN("cui.dialogs", "CreateStream <" << rURL << "> failed"); @@ -404,7 +405,10 @@ void SearchAndParseThread::execute() if (m_bIsFirstLoading) { - std::string sResponse = !m_bUITest ? ucbGet(m_pAdditionsDialog->m_sURL) : ""; + const auto pDialog = m_pAdditionsDialog->getDialog(); + std::string sResponse = !m_bUITest ? ucbGet(m_pAdditionsDialog->m_sURL, + pDialog ? pDialog->GetXWindow() : nullptr) + : ""; parseResponse(sResponse, m_pAdditionsDialog->m_aAllExtensionsVector); std::sort(m_pAdditionsDialog->m_aAllExtensionsVector.begin(), m_pAdditionsDialog->m_aAllExtensionsVector.end(), diff --git a/include/unotools/ucbstreamhelper.hxx b/include/unotools/ucbstreamhelper.hxx index 69bae538b316..3c8868c03911 100644 --- a/include/unotools/ucbstreamhelper.hxx +++ b/include/unotools/ucbstreamhelper.hxx @@ -39,9 +39,14 @@ namespace utl class UNOTOOLS_DLLPUBLIC UcbStreamHelper { public: - static std::unique_ptr<SvStream> CreateStream(const OUString& rFileName, StreamMode eOpenMode, css::uno::Reference<css::awt::XWindow> xParentWin = nullptr); - static std::unique_ptr<SvStream> CreateStream(const OUString& rFileName, StreamMode eOpenMode, - bool bFileExists, css::uno::Reference<css::awt::XWindow> xParentWin = nullptr); + static std::unique_ptr<SvStream> + CreateStream(const OUString& rFileName, StreamMode eOpenMode, + css::uno::Reference<css::awt::XWindow> xParentWin = nullptr, + bool bUseSimpleFileAccessInteraction = true); + static std::unique_ptr<SvStream> + CreateStream(const OUString& rFileName, StreamMode eOpenMode, bool bFileExists, + css::uno::Reference<css::awt::XWindow> xParentWin = nullptr, + bool bUseSimpleFileAccessInteraction = true); static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream ); static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XStream >& xStream ); static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream, bool bCloseStream ); diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index 96c0a4f1de61..4b3589ea7bf9 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -2258,6 +2258,19 @@ uno::Any Content::open( && aDAVOptions.getHttpResponseStatusCode() != SC_INTERNAL_SERVER_ERROR) { // throws exception as if there was a server error, a DAV exception + switch (aDAVOptions.getHttpResponseStatusCode()) + { + case USC_CONNECT_FAILED: + { + CurlUri aUri(aTargetURL); + throw DAVException( + DAVException::DAV_HTTP_CONNECT, + ConnectionEndPointString(aUri.GetHost(), aUri.GetPort()), + aDAVOptions.getHttpResponseStatusText()); + } + default: + break; + } throw DAVException( DAVException::DAV_HTTP_ERROR, aDAVOptions.getHttpResponseStatusText(), aDAVOptions.getHttpResponseStatusCode() ); diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx index 72a3d7cbe64b..f68a503370c1 100644 --- a/unotools/source/ucbhelper/ucbstreamhelper.cxx +++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx @@ -137,24 +137,37 @@ static std::unique_ptr<SvStream> lcl_CreateStream( const OUString& rFileName, St return pStream; } -std::unique_ptr<SvStream> UcbStreamHelper::CreateStream(const OUString& rFileName, StreamMode eOpenMode, css::uno::Reference<css::awt::XWindow> xParentWin) +std::unique_ptr<SvStream> +UcbStreamHelper::CreateStream(const OUString& rFileName, StreamMode eOpenMode, + css::uno::Reference<css::awt::XWindow> xParentWin, + bool bUseSimpleFileAccessInteraction) { // related tdf#99312 // create a specialized interaction handler to manages Web certificates and Web credentials when needed Reference< XInteractionHandler > xIH( css::task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), xParentWin)); + + if (!bUseSimpleFileAccessInteraction) + return lcl_CreateStream(rFileName, eOpenMode, xIH, true /* bEnsureFileExists */); + Reference<XInteractionHandler> xIHScoped(new comphelper::SimpleFileAccessInteraction(xIH)); return lcl_CreateStream( rFileName, eOpenMode, xIHScoped, true /* bEnsureFileExists */ ); } -std::unique_ptr<SvStream> UcbStreamHelper::CreateStream(const OUString& rFileName, StreamMode eOpenMode, - bool bFileExists, css::uno::Reference<css::awt::XWindow> xParentWin) +std::unique_ptr<SvStream> +UcbStreamHelper::CreateStream(const OUString& rFileName, StreamMode eOpenMode, bool bFileExists, + css::uno::Reference<css::awt::XWindow> xParentWin, + bool bUseSimpleFileAccessInteraction) { // related tdf#99312 // create a specialized interaction handler to manages Web certificates and Web credentials when needed Reference< XInteractionHandler > xIH( css::task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), xParentWin)); + + if (!bUseSimpleFileAccessInteraction) + return lcl_CreateStream(rFileName, eOpenMode, xIH, !bFileExists); + Reference<XInteractionHandler> xIHScoped(new comphelper::SimpleFileAccessInteraction(xIH)); return lcl_CreateStream( rFileName, eOpenMode, xIHScoped,!bFileExists ); }