diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-15 11:39:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-16 12:19:05 +0100 |
commit | e6a7537762e19fde446441edd10d301f9b37ce75 (patch) | |
tree | 4e43dab00eddfb528bdde4e21b0f94530f12c545 /sfx2/source/doc | |
parent | 60f001962122a77863231e9cf5dc445c136aac43 (diff) |
reorg calc hyperlink check to reuse elsewhere
Change-Id: I20ae3c5df15502c3a0a366fb4a2924c06ffac3d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159487
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index a3735bdc6826..57deb4fe9de8 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -968,6 +968,33 @@ bool SfxObjectShell::GetHadCheckedMacrosOnLoad() const return pImpl->m_bHadCheckedMacrosOnLoad; } +bool SfxObjectShell::AllowedLinkProtocolFromDocument(const OUString& rUrl, SfxObjectShell* pObjShell, weld::Window* pDialogParent) +{ + if (!INetURLObject(rUrl).IsExoticProtocol()) + return true; + // Default to ignoring exotic protocols + bool bAllow = false; + if (pObjShell) + { + // If the document had macros when loaded then follow the allowed macro-mode + if (pObjShell->GetHadCheckedMacrosOnLoad()) + bAllow = pObjShell->AdjustMacroMode(); + else // otherwise ask the user, defaulting to cancel + { + //Reuse URITools::onOpenURI warning string + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pDialogParent, + VclMessageType::Warning, VclButtonsType::YesNo, + SfxResId(STR_DANGEROUS_TO_OPEN))); + xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)", + INetURLObject::decode(rUrl, INetURLObject::DecodeMechanism::Unambiguous))); + xQueryBox->set_default_response(RET_NO); + bAllow = xQueryBox->run() == RET_YES; + } + } + SAL_WARN_IF(!bAllow, "sfx.appl", "SfxObjectShell::AllowedLinkProtocolFromDocument ignoring: " << rUrl); + return bAllow; +} + void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler ) { OUString aVersion; |