sc/source/ui/view/viewfun2.cxx | 8 ++++++++ 1 file changed, 8 insertions(+)
New commits: commit f079d05bc0311940cf527ab2516a974097fbbf17 Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Tue Mar 25 10:05:02 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Mar 27 09:56:12 2025 +0100 sc: avoid cursor jump on failed search When using the command .uno:ExecuteSearch with the SearchStartPointX/Y options, the cursor would change position even if no matching string is found in the sheet. Change-Id: I94471b79b00a882489e0c92295c8359d68ee3372 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183292 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183365 diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 8c93a2fe393a..c1b8a67218e5 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1970,6 +1970,9 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, if (bAddUndo && !rDoc.IsUndoEnabled()) bAddUndo = false; + bool bCursorMoved = false; + SCCOL nOrigPosX = GetViewData().GetCurX(); + SCROW nOrigPosY = GetViewData().GetCurY(); if ( !rMark.IsMarked() && !rMark.IsMultiMarked() && (pSearchItem->HasStartPoint()) ) { // No selection -> but we have a start point (top left corner of the @@ -1985,6 +1988,7 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, AlignToCursor( nPosX, nPosY, SC_FOLLOW_JUMP ); SetCursor( nPosX, nPosY, true ); + bCursorMoved = true; } SCCOL nCol, nOldCol; @@ -2260,6 +2264,10 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, pDocSh->PostPaintGridAll(); // mark GetFrameWin()->LeaveWait(); } + else if (bCursorMoved) + { + SetCursor(nOrigPosX, nOrigPosY, true); + } return bFound; }