From: Samuel Mehrbrodt Date: Tue, 16 Jul 2019 14:42:53 +0000 (+0200) Subject: PATCH] tdf#126393 Select cell even when clicking on a hyperlink X-Git-Tag: archive/raspbian/1%6.1.5-3+rpi1+deb10u11^2~9 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=923b226356c03e9706e12494886dc2f54224c5e5;p=libreoffice.git PATCH] tdf#126393 Select cell even when clicking on a hyperlink and the hyperlink isn't being opened anyway (no ctrl clicked e.g.) Change-Id: Ic0c0df9b91000a8e661075901e8bfdb7167081f9 Reviewed-on: https://gerrit.libreoffice.org/75730 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt Gbp-Pq: Name 0089-PATCH-tdf-126393-Select-cell-even-when-clicking-on-a.patch --- diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index b888b52a116..0da91cf7ab6 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -568,6 +568,8 @@ public: static void SetUserList( const ScUserList* pNewList ); /// Open the specified URL. static void OpenURL(const OUString& rURL, const OUString& rTarget); + /// Whether the URL can be opened according to current security options (Click/Ctrl-Click) + static bool ShouldOpenURL(); SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName, const SfxObjectShell* pShell ); SC_DLLPUBLIC static OUString GetDocTabName( const OUString& rFileName, diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 8360fb4dad0..2a4f14a8b75 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -802,22 +802,9 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget) { // OpenURL is always called in the GridWindow by mouse clicks in some way or another. // That's why pScActiveViewShell and nScClickMouseModifier are correct. - // SvtSecurityOptions to access Libreoffice global security parameters - SvtSecurityOptions aSecOpt; - bool bCtrlClickHappened = (nScClickMouseModifier & KEY_MOD1); - bool bCtrlClickSecOption = aSecOpt.IsOptionSet( SvtSecurityOptions::EOption::CtrlClickHyperlink ); - if( bCtrlClickHappened && ! bCtrlClickSecOption ) - { - // return since ctrl+click happened when the - // ctrl+click security option was disabled, link should not open - return; - } - else if( ! bCtrlClickHappened && bCtrlClickSecOption ) - { - // ctrl+click did not happen; only click happened maybe with some - // other key combo. and security option is set, so return + + if (!ShouldOpenURL()) return; - } SfxViewFrame* pViewFrm = SfxViewFrame::Current(); if (!pViewFrm) @@ -869,6 +856,26 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget) { &aUrl, &aTarget, &aFrm, &aReferer, &aNewView, &aBrowsing }); } +bool ScGlobal::ShouldOpenURL() +{ + SvtSecurityOptions aSecOpt; + bool bCtrlClickHappened = (nScClickMouseModifier & KEY_MOD1); + bool bCtrlClickSecOption = aSecOpt.IsOptionSet( SvtSecurityOptions::EOption::CtrlClickHyperlink ); + if( bCtrlClickHappened && ! bCtrlClickSecOption ) + { + // return since ctrl+click happened when the + // ctrl+click security option was disabled, link should not open + return false; + } + else if( ! bCtrlClickHappened && bCtrlClickSecOption ) + { + // ctrl+click did not happen; only click happened maybe with some + // other key combo. and security option is set, so return + return false; + } + return true; +} + bool ScGlobal::IsSystemRTL() { return MsLangId::isRightToLeft( Application::GetSettings().GetLanguageTag().getLanguageType() ); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 2510bf5a9f5..bc34de0cd0d 100644 Binary files a/sc/source/ui/view/gridwin.cxx and b/sc/source/ui/view/gridwin.cxx differ