summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-10-29 19:50:50 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-10-31 15:06:37 +0100
commitb73bf4a5fca4fcfff24b234a7337c7a25d75887d (patch)
tree3a15728b81beed79865bb85da04029488ac083a3
parent5f909fb33210f98905d5ef37d9176fecf4ba5c29 (diff)
pass an explicit parent to use for any warning dialogs
Change-Id: I7909775b63dfe830e5f0e5b024fa6b47a074736a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124457 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sfx2/source/appl/appopen.cxx4
-rw-r--r--sfx2/source/appl/appserv.cxx14
-rw-r--r--sfx2/source/appl/openuriexternally.cxx19
-rw-r--r--sfx2/source/appl/sfxhelp.cxx31
-rw-r--r--sfx2/source/inc/openuriexternally.hxx8
-rw-r--r--sfx2/source/view/viewsh.cxx2
6 files changed, 42 insertions, 36 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index fa95d74ca458..5d8a28b7d21c 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -859,7 +859,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
aINetProtocol == INetProtocol::Http ||
aINetProtocol == INetProtocol::Https )
{
- sfx2::openUriExternally(aURL.Complete, true);
+ sfx2::openUriExternally(aURL.Complete, true, rReq.GetFrameWeld());
return;
}
else
@@ -904,7 +904,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
try
{
sfx2::openUriExternally(
- aURL.Complete, pFilter == nullptr);
+ aURL.Complete, pFilter == nullptr, rReq.GetFrameWeld());
}
catch ( css::system::SystemShellExecuteException& )
{
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 6be2bfc85d40..816dfa668d69 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -482,7 +482,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
"?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
"&LOlocale=" + utl::ConfigManager::getUILocale() +
"&LOmodule=" + module.subView(module.lastIndexOf('.') + 1 ) );
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
@@ -493,7 +493,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
OUString sURL(officecfg::Office::Common::Menus::QA_URL::get() + //https://hub.libreoffice.org/forum/
"?LOlocale=" + utl::ConfigManager::getUILocale());
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
case SID_DOCUMENTATION:
@@ -501,7 +501,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
// Open documentation page based on locales
OUString sURL(officecfg::Office::Common::Menus::DocumentationURL::get() + //https://hub.libreoffice.org/documentation/
"?LOlocale=" + utl::ConfigManager::getUILocale());
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
case SID_GETINVOLVED:
@@ -509,7 +509,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
// Open get involved/join us page based on locales
OUString sURL(officecfg::Office::Common::Menus::GetInvolvedURL::get() + //https://hub.libreoffice.org/joinus/
"?LOlocale=" + utl::ConfigManager::getUILocale());
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
case SID_DONATION:
@@ -519,7 +519,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
OUString aBcp47 = LanguageTag(utl::ConfigManager::getUILocale()).getBcp47();
OUString sURL(officecfg::Office::Common::Menus::DonationURL::get() + //https://hub.libreoffice.org/donation/
"?BCP47=" + aBcp47 + "&LOlang=" + aLang );
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
case SID_WHATSNEW:
@@ -528,7 +528,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
OUString sURL(officecfg::Office::Common::Menus::ReleaseNotesURL::get() + //https://hub.libreoffice.org/ReleaseNotes/
"?LOvers=" + utl::ConfigManager::getProductVersion() +
"&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47() );
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
case SID_HYPHENATIONMISSING:
@@ -536,7 +536,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
// Open wiki page about hyphenation
OUString sURL(officecfg::Office::Common::Menus::HyphenationMissingURL::get() + //https://hub.libreoffice.org/HyphenationMissing/
"?LOlocale=" + utl::ConfigManager::getUILocale());
- sfx2::openUriExternally(sURL, false);
+ sfx2::openUriExternally(sURL, false, rReq.GetFrameWeld());
break;
}
case SID_SHOW_LICENSE:
diff --git a/sfx2/source/appl/openuriexternally.cxx b/sfx2/source/appl/openuriexternally.cxx
index 0425da7208be..ebc5886ea5b8 100644
--- a/sfx2/source/appl/openuriexternally.cxx
+++ b/sfx2/source/appl/openuriexternally.cxx
@@ -17,7 +17,6 @@
#include <com/sun/star/uno/RuntimeException.hpp>
#include <comphelper/processfactory.hxx>
#include <rtl/ustring.hxx>
-#include <sfx2/app.hxx>
#include <sfx2/sfxresid.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -35,12 +34,14 @@ class URITools
private:
Timer aOpenURITimer { "sfx2::openUriExternallyTimer" };
OUString msURI;
+ weld::Widget* mpDialogParent;
bool mbHandleSystemShellExecuteException;
DECL_LINK(onOpenURI, Timer*, void);
public:
- URITools()
- : mbHandleSystemShellExecuteException(false)
+ URITools(weld::Widget* pDialogParent)
+ : mpDialogParent(pDialogParent)
+ , mbHandleSystemShellExecuteException(false)
{
}
void openURI(const OUString& sURI, bool bHandleSystemShellExecuteException);
@@ -89,11 +90,10 @@ IMPL_LINK_NOARG(URITools, onOpenURI, Timer*, void)
"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,
+ mpDialogParent, 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) {
@@ -101,7 +101,7 @@ IMPL_LINK_NOARG(URITools, onOpenURI, Timer*, void)
continue;
}
} else {
- std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(pWindow,
+ std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(mpDialogParent,
VclMessageType::Warning, VclButtonsType::Ok,
SfxResId(STR_NO_ABS_URI_REF)));
eb->set_primary_text(eb->get_primary_text().replaceFirst("$(ARG1)", msURI));
@@ -112,8 +112,7 @@ IMPL_LINK_NOARG(URITools, onOpenURI, Timer*, void)
throw;
}
SolarMutexGuard g;
- weld::Window *pWindow = SfxGetpApp()->GetTopWindow();
- std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(pWindow,
+ std::unique_ptr<weld::MessageDialog> eb(Application::CreateMessageDialog(mpDialogParent,
VclMessageType::Warning, VclButtonsType::Ok,
SfxResId(STR_NO_WEBBROWSER_FOUND)));
eb->set_primary_text(
@@ -127,9 +126,9 @@ IMPL_LINK_NOARG(URITools, onOpenURI, Timer*, void)
}
}
-void sfx2::openUriExternally(const OUString& sURI, bool bHandleSystemShellExecuteException)
+void sfx2::openUriExternally(const OUString& sURI, bool bHandleSystemShellExecuteException, weld::Widget* pDialogParent)
{
- URITools* uriTools = new URITools;
+ URITools* uriTools = new URITools(pDialogParent);
uriTools->openURI(sURI, bHandleSystemShellExecuteException);
}
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 039b85bb1e27..73d86cba8266 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -712,7 +712,7 @@ bool SfxHelp::Start(const OUString& rURL, weld::Widget* pWidget)
}
/// Redirect the vnd.sun.star.help:// urls to http://help.libreoffice.org
-static bool impl_showOnlineHelp( const OUString& rURL )
+static bool impl_showOnlineHelp(const OUString& rURL, weld::Widget* pDialogParent)
{
static constexpr OUStringLiteral aInternal(u"vnd.sun.star.help://");
if ( rURL.getLength() <= aInternal.getLength() || !rURL.startsWith(aInternal) )
@@ -750,8 +750,9 @@ static bool impl_showOnlineHelp( const OUString& rURL )
kCFStringEncodingUTF8),
nullptr),
nullptr);
+ (void)pDialogParent;
#else
- sfx2::openUriExternally(aHelpLink, false);
+ sfx2::openUriExternally(aHelpLink, false, pDialogParent);
#endif
return true;
}
@@ -939,7 +940,7 @@ constexpr OUStringLiteral SHTML4 = u"'\"><script type=\"text/javascript\"> windo
constexpr OUStringLiteral SHTML5 = u"\";</script><title>Help Page Redirection</title></head><body></body></html>";
// use a tempfile since e.g. xdg-open doesn't support URL-parameters with file:// URLs
-static bool impl_showOfflineHelp( const OUString& rURL )
+static bool impl_showOfflineHelp(const OUString& rURL, weld::Widget* pDialogParent)
{
OUString aBaseInstallPath = getHelpRootURL();
// For the flatpak case, find the pathname outside the flatpak sandbox that corresponds to
@@ -982,8 +983,9 @@ static bool impl_showOfflineHelp( const OUString& rURL )
kCFStringEncodingUTF8),
nullptr),
nullptr);
+ (void)pDialogParent;
#else
- sfx2::openUriExternally(aTempFile.GetURL(), false);
+ sfx2::openUriExternally(aTempFile.GetURL(), false, pDialogParent);
#endif
return true;
}
@@ -1102,9 +1104,12 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow)
}
}
+ pWindow = GetBestParent(pWindow);
+ weld::Window* pWeldWindow = pWindow ? pWindow->GetFrameWeld() : nullptr;
+
if ( comphelper::LibreOfficeKit::isActive() )
{
- impl_showOnlineHelp( aHelpURL );
+ impl_showOnlineHelp(aHelpURL, pWeldWindow);
return true;
}
#ifdef MACOSX
@@ -1118,7 +1123,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow)
nullptr),
kLSRolesAll, nullptr);
if([static_cast<NSString*>(CFURLGetString(pBrowser)) isEqualToString:@"file:///Applications/Safari.app/"]) {
- impl_showOnlineHelp( aHelpURL );
+ impl_showOnlineHelp(aHelpURL, pWeldWindow);
return true;
}
}
@@ -1130,7 +1135,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow)
// display" code below:
if (SfxContentHelper::IsHelpErrorDocument(aHelpURL))
{
- if ( impl_hasHTMLHelpInstalled() && impl_showOfflineHelp(aHelpURL) )
+ if ( impl_hasHTMLHelpInstalled() && impl_showOfflineHelp(aHelpURL, pWeldWindow) )
{
return true;
}
@@ -1139,13 +1144,10 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow)
{
bool bShowOfflineHelpPopUp = officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::get();
- pWindow = GetBestParent(pWindow);
-
TopLevelWindowLocker aBusy;
if(bShowOfflineHelpPopUp)
{
- weld::Window* pWeldWindow = pWindow ? pWindow->GetFrameWeld() : nullptr;
aBusy.incBusy(pWeldWindow);
HelpManualMessage aQueryBox(pWeldWindow);
short OnlineHelpBox = aQueryBox.run();
@@ -1157,11 +1159,10 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow)
}
if(!bShowOfflineHelpPopUp)
{
- if ( impl_showOnlineHelp( aHelpURL ) )
+ if ( impl_showOnlineHelp(aHelpURL, pWeldWindow) )
return true;
else
{
- weld::Window* pWeldWindow = pWindow ? pWindow->GetFrameWeld() : nullptr;
aBusy.incBusy(pWeldWindow);
NoHelpErrorBox aErrBox(pWeldWindow);
aErrBox.run();
@@ -1277,7 +1278,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt
if ( comphelper::LibreOfficeKit::isActive() )
{
- impl_showOnlineHelp( aHelpURL );
+ impl_showOnlineHelp(aHelpURL, pWidget);
return true;
}
@@ -1287,7 +1288,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt
// display" code below:
if (SfxContentHelper::IsHelpErrorDocument(aHelpURL))
{
- if ( impl_hasHTMLHelpInstalled() && impl_showOfflineHelp(aHelpURL) )
+ if ( impl_hasHTMLHelpInstalled() && impl_showOfflineHelp(aHelpURL, pWidget) )
{
return true;
}
@@ -1311,7 +1312,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt
}
if(!bShowOfflineHelpPopUp)
{
- if ( impl_showOnlineHelp( aHelpURL ) )
+ if ( impl_showOnlineHelp(aHelpURL, pWidget) )
return true;
else
{
diff --git a/sfx2/source/inc/openuriexternally.hxx b/sfx2/source/inc/openuriexternally.hxx
index a7eca291c7c3..cf78d1b71370 100644
--- a/sfx2/source/inc/openuriexternally.hxx
+++ b/sfx2/source/inc/openuriexternally.hxx
@@ -14,6 +14,11 @@
#include <rtl/ustring.hxx>
+namespace weld
+{
+class Widget;
+}
+
namespace sfx2
{
/** Open a URI via com.sun.star.system.SystemShellExecute
@@ -26,7 +31,8 @@ namespace sfx2
given bHandleSystemShellExecuteException is false (in which case the
exception is re-thrown).
*/
-void openUriExternally(const OUString& sURI, bool bHandleSystemShellExecuteException);
+void openUriExternally(const OUString& sURI, bool bHandleSystemShellExecuteException,
+ weld::Widget* pDialogParent);
};
#endif
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 7b86b27cabf6..e49899bc36eb 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -639,7 +639,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
return;
}
- sfx2::openUriExternally(aFileURL, true);
+ sfx2::openUriExternally(aFileURL, true, rReq.GetFrameWeld());
rReq.Done(true);
break;
}