diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-10-29 11:17:09 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-10-29 13:26:36 +0200 |
commit | 70009098fd70df021048c540d1796c928554b494 (patch) | |
tree | bf22be8ebd1b2080c48d6255906869c70554b0c8 /sfx2 | |
parent | a5cea74034a8e029bfdf0f2b82ea8800bf5bd206 (diff) |
tdf#128969: Let the user explicitly decide to execute an external program
...bringing up a warning dialog now in cases where it would have before only
brought up a failure message
Change-Id: I850badf5927517f16f965950df699979887dbdc0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124422
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/openuriexternally.cxx | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/sfx2/source/appl/openuriexternally.cxx b/sfx2/source/appl/openuriexternally.cxx index d149f63d257d..0425da7208be 100644 --- a/sfx2/source/appl/openuriexternally.cxx +++ b/sfx2/source/appl/openuriexternally.cxx @@ -80,37 +80,50 @@ IMPL_LINK_NOARG(URITools, onOpenURI, Timer*, void) std::unique_ptr<URITools> guard(this); css::uno::Reference< css::system::XSystemShellExecute > exec( css::system::SystemShellExecute::create(comphelper::getProcessComponentContext())); - try { - exec->execute( - msURI, OUString(), - css::system::SystemShellExecuteFlags::URIS_ONLY); - } catch (css::lang::IllegalArgumentException & e) { - if (e.ArgumentPosition != 0) { - throw css::uno::RuntimeException( - "unexpected IllegalArgumentException: " + e.Message); + for (sal_Int32 flags = css::system::SystemShellExecuteFlags::URIS_ONLY;;) { + try { + exec->execute(msURI, OUString(), flags); + } catch (css::lang::IllegalArgumentException & e) { + if (e.ArgumentPosition != 0) { + throw css::uno::RuntimeException( + "unexpected IllegalArgumentException: " + e.Message); + } + SolarMutexGuard g; + weld::Window *pWindow = SfxGetpApp()->GetTopWindow(); + if (flags == css::system::SystemShellExecuteFlags::URIS_ONLY) { + std::unique_ptr<weld::MessageDialog> eb( + Application::CreateMessageDialog( + pWindow, VclMessageType::Warning, VclButtonsType::OkCancel, + SfxResId(STR_DANGEROUS_TO_OPEN))); + eb->set_primary_text(eb->get_primary_text().replaceFirst("$(ARG1)", msURI)); + if (eb->run() == RET_OK) { + flags = 0; + continue; + } + } else { + std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(pWindow, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_NO_ABS_URI_REF))); + eb->set_primary_text(eb->get_primary_text().replaceFirst("$(ARG1)", msURI)); + eb->run(); + } + } catch (css::system::SystemShellExecuteException & e) { + if (!mbHandleSystemShellExecuteException) { + throw; + } + SolarMutexGuard g; + weld::Window *pWindow = SfxGetpApp()->GetTopWindow(); + std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(pWindow, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_NO_WEBBROWSER_FOUND))); + eb->set_primary_text( + eb->get_primary_text().replaceFirst("$(ARG1)", msURI) + .replaceFirst("$(ARG2)", OUString::number(e.PosixError)) + .replaceFirst("$(ARG3)", e.Message)); + //TODO: avoid subsequent replaceFirst acting on previous replacement + eb->run(); } - SolarMutexGuard g; - weld::Window *pWindow = SfxGetpApp()->GetTopWindow(); - std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(pWindow, - VclMessageType::Warning, VclButtonsType::Ok, - SfxResId(STR_NO_ABS_URI_REF))); - eb->set_primary_text(eb->get_primary_text().replaceFirst("$(ARG1)", msURI)); - eb->run(); - } catch (css::system::SystemShellExecuteException & e) { - if (!mbHandleSystemShellExecuteException) { - throw; - } - SolarMutexGuard g; - weld::Window *pWindow = SfxGetpApp()->GetTopWindow(); - std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(pWindow, - VclMessageType::Warning, VclButtonsType::Ok, - SfxResId(STR_NO_WEBBROWSER_FOUND))); - eb->set_primary_text( - eb->get_primary_text().replaceFirst("$(ARG1)", msURI) - .replaceFirst("$(ARG2)", OUString::number(e.PosixError)) - .replaceFirst("$(ARG3)", e.Message)); - //TODO: avoid subsequent replaceFirst acting on previous replacement - eb->run(); + break; } } |