Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


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.johnsson@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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.