Also one of the easy hacks. Patch ensures that after doing "replace all" the cursor is left at original position, rather than moved to the position of the last replacement.
Code contributed under MPL 1.1 / GPLv3+ / LGPLv3+ licenses. Cheers, Mattias
From 5f26ecaf56db73b8877808ca716276f1b3245474 Mon Sep 17 00:00:00 2001 From: Mattias Johnsson <m.t.johns...@gmail.com> Date: Sun, 28 Nov 2010 13:37:12 +1100 Subject: [PATCH] Fix for i#12345: "Replace all" should leave the cursor at original position --- sw/source/ui/uiview/viewsrch.cxx | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx index 09782b0..1d68817 100644 --- a/sw/source/ui/uiview/viewsrch.cxx +++ b/sw/source/ui/uiview/viewsrch.cxx @@ -286,6 +286,10 @@ void SwView::ExecSearch(SfxRequest& rReq, BOOL bNoMessage) { SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() ); + // Fix for i#12345: "Replace all" should leave the cursor at the place it was + // before executing the command, rather than at the site of the final replacement. + // To do this take note of the current cursor position before replace all begins: + SwPosition TmpPointPos = *pWrtShell->GetSwCrsr()->GetPoint(); if( !pSrchItem->GetSelection() ) { @@ -305,8 +309,13 @@ void SwView::ExecSearch(SfxRequest& rReq, BOOL bNoMessage) SwWait aWait( *GetDocShell(), TRUE ); pWrtShell->StartAllAction(); nFound = FUNC_Search( aOpts ); + + // i#12345: Now that everything has been replaced, restore the original cursor position. + *(pWrtShell->GetSwCrsr()->GetPoint()) = TmpPointPos; + pWrtShell->EndAllAction(); } + rReq.SetReturnValue(SfxBoolItem(nSlot, nFound != 0 && ULONG_MAX != nFound)); if( !nFound ) { -- 1.7.1
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice