[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 2 commits - sw/source

Michael Stahl mst at kemper.freedesktop.org
Fri Dec 9 10:55:30 PST 2011


 sw/source/core/doc/docedt.cxx    |    7 +++++--
 sw/source/ui/uiview/viewsrch.cxx |   17 +++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 4eec19b1d634b66580423eb995621f87b422a46a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Nov 18 14:12:42 2011 +0100

    fdo#40831: SwView::ExecSearch:
    
    Replace may delete nodes, so the current cursor position must be stored
    in a way so that it is corrected when nodes are removed.
    
    Signed-off-by: Michael Meeks <michael.meeks at suse.com>

diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index b3e8d6e..cf4e14a 100644
--- a/sw/source/ui/uiview/viewsrch.cxx
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -30,6 +30,9 @@
 #include "precompiled_sw.hxx"
 
 #include <string>
+
+#include <boost/scoped_ptr.hpp>
+
 #include <hintids.hxx>
 #include <com/sun/star/util/SearchOptions.hpp>
 #include <svl/cjkoptions.hxx>
@@ -57,6 +60,8 @@
 #include <uitool.hxx>
 #include <cmdid.h>
 #include <docsh.hxx>
+#include <doc.hxx>
+#include <unocrsr.hxx>
 
 #include <view.hrc>
 #include <SwRewriter.hxx>
@@ -283,7 +288,14 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
             case SVX_SEARCHCMD_REPLACE_ALL:
                 {
                     SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
-                    SwCrsrSaveState aSaveCursor( *pWrtShell->GetSwCrsr());
+
+                    // Fix for i#8288: "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:
+                    // note: must be stored so that it is corrected by PamCorr*
+                    ::boost::scoped_ptr<SwUnoCrsr> const pTmpCursor(
+                            pWrtShell->GetDoc()->CreateUnoCrsr(
+                                *pWrtShell->GetSwCrsr()->GetPoint()));
 
                     if( !pSrchItem->GetSelection() )
                     {
@@ -304,7 +316,8 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
                         pWrtShell->StartAllAction();
                         nFound = FUNC_Search( aOpts );
                         // #i8288# Now that everything has been replaced, restore the original cursor position.
-                        pWrtShell->GetSwCrsr()->RestoreSavePos();  // (position saved by SwCrsrSaveState above)
+                        *(pWrtShell->GetSwCrsr()->GetPoint()) =
+                            *pTmpCursor->GetPoint();
                         pWrtShell->EndAllAction();
                     }
 
commit f4fb39640571fd588299ecd603733eaf94e61605
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Nov 18 14:07:11 2011 +0100

    i#102333: SwDoc::ReplaceRangeImpl:
    
    The fix for this (230fcf4a456636bb466f72834cd57238621d206d) was not
    quite right; there are 2 different join modes, and moving the cursor
    backward is required in one of them, but not the other.
    
    This can be seen when doing replace all ^$ with several consecutive
    empty lines.
    
    Signed-off-by: Michael Meeks <michael.meeks at suse.com>

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 297c42f..b6eadc3 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -2482,8 +2482,11 @@ SetRedlineMode( eOld );
             rPam.GetMark()->nNode = aPtNd;
             rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
                                                 nPtCnt );
-            if( bJoinTxt )
-                rPam.Move( fnMoveBackward );
+
+            if (bJoinTxt && !bJoinPrev)
+            {
+                rPam.Move(fnMoveBackward);
+            }
 
             if( pUndoRpl )
             {


More information about the Libreoffice-commits mailing list