PATCH] tdf#126393 Select cell even when clicking on a hyperlink
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tue, 16 Jul 2019 14:42:53 +0000 (16:42 +0200)
committerBastien Roucariès <rouca@debian.org>
Fri, 29 Dec 2023 09:39:36 +0000 (09:39 +0000)
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 <Samuel.Mehrbrodt@cib.de>
Gbp-Pq: Name 0089-PATCH-tdf-126393-Select-cell-even-when-clicking-on-a.patch

sc/inc/global.hxx
sc/source/core/data/global.cxx
sc/source/ui/view/gridwin.cxx

index b888b52a116ef6aef7915701da7cbf9d8394ec7d..0da91cf7ab6e7e77fc27a605e8e36a224a49d155 100644 (file)
@@ -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,
index 8360fb4dad000baf7ff3aeddb8b83a2561626e3b..2a4f14a8b754a2e0cf1a8df053039506d1600b35 100644 (file)
@@ -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() );
index 2510bf5a9f5d575a7af3dd26a4a20fad356f7a8b..bc34de0cd0dbb03c648ac6d5b74dcc1c17fe3cee 100644 (file)
Binary files a/sc/source/ui/view/gridwin.cxx and b/sc/source/ui/view/gridwin.cxx differ