From 25c390e17a7f1c018b5eed1ef7dfd568b76f4a84 Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Sat, 2 Nov 2019 12:51:36 -0800 Subject: tdf#38199 Readonly mode tab key: Don't scroll if no hyperlink found When viewing a document in readonly mode the action of the tab key is to move among Graphic, Frame, Ole, DrawObject, or DbForm if one these is already selected. If the cursor is inside an input field and has no multi selection then move among InputFields. Finally if neither the previous two cases apply then move among Hyperlinks which causes cursor position to move to top or bottom of the document when no Hyperlink is found. When no Hyperlink is found this patch restores the cursor position to the position before search and does not scroll to it on EndAction. Change-Id: I94ac882e7be124d2ddb6f86daac03a9389117cc5 Reviewed-on: https://gerrit.libreoffice.org/81955 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- sw/source/uibase/wrtsh/select.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx index e06f3dc69777..90664ae098f5 100644 --- a/sw/source/uibase/wrtsh/select.cxx +++ b/sw/source/uibase/wrtsh/select.cxx @@ -941,15 +941,22 @@ void SwWrtShell::SelectNextPrevHyperlink( bool bNext ) { StartAction(); bool bRet = SwCursorShell::SelectNxtPrvHyperlink( bNext ); - if( !bRet ) + if( !bRet ) // didn't find? wrap and check again { - // will we have this feature? + SwShellCursor* pCursor = GetCursor_(); + SwCursorSaveState aSaveState(*pCursor); EnterStdMode(); if( bNext ) SttEndDoc(true); else SttEndDoc(false); - SwCursorShell::SelectNxtPrvHyperlink( bNext ); + bRet = SwCursorShell::SelectNxtPrvHyperlink(bNext); + if (!bRet) // didn't find again? restore cursor position and bail + { + pCursor->RestoreSavePos(); + EndAction(true); // don't scroll to restored cursor position + return; + } } EndAction(); -- cgit