sc/inc/global.hxx | 2 ++ sc/source/core/data/global.cxx | 37 ++++++++++++++++++++++--------------- sc/source/ui/view/gridwin.cxx | 6 +++--- 3 files changed, 27 insertions(+), 18 deletions(-)
New commits: commit 22069f3d5d1c00551bd254d1002966e515295475 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> AuthorDate: Tue Jul 16 16:42:53 2019 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> CommitDate: Wed Jul 17 09:04:13 2019 +0200 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 <samuel.mehrbr...@cib.de> diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 0c1447f16721..c71403ebcdeb 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -567,6 +567,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 d91222c117bc..53855d39c4fe 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -778,22 +778,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) @@ -852,6 +839,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 3d0c88868b94..d7c23d5696dc 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1805,7 +1805,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta // links in the edit cell bool bAlt = rMEvt.IsMod2(); - if ( !bAlt && rMEvt.IsLeft() && + if ( !bAlt && rMEvt.IsLeft() && ScGlobal::ShouldOpenURL() && GetEditUrl(rMEvt.GetPosPixel()) ) // click on link: do not move cursor { SetPointer( PointerStyle::RefHand ); @@ -2452,7 +2452,7 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt ) } // Field can only be URL field bool bAlt = rMEvt.IsMod2(); - if ( !bAlt && !nButtonDown && pFld ) + if ( !bAlt && !nButtonDown && ScGlobal::ShouldOpenURL() && pFld ) SetPointer( PointerStyle::RefHand ); else if ( pEditView->GetEditEngine()->IsVertical() ) SetPointer( PointerStyle::TextVertical ); @@ -2533,7 +2533,7 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt ) if (bEditMode) // First has to be in edit mode! SetPointer( PointerStyle::Arrow ); - else if ( !bAlt && !nButtonDown && + else if ( !bAlt && !nButtonDown && ScGlobal::ShouldOpenURL() && GetEditUrl(rMEvt.GetPosPixel()) ) SetPointer( PointerStyle::RefHand ); else if ( DrawMouseMove(rMEvt) ) // Reset pointer _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits