summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2011-11-18 14:12:42 +0100
committerMichael Stahl <mstahl@redhat.com>2011-11-18 22:24:19 +0100
commit82a716f29cc252740c80556f72f9d9e602877918 (patch)
tree965e008512198c03f33870fcefb91593e102be47 /sw
parenti#102333: SwDoc::ReplaceRangeImpl: (diff)
downloadcore-82a716f29cc252740c80556f72f9d9e602877918.tar.gz
core-82a716f29cc252740c80556f72f9d9e602877918.zip
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.
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/uiview/viewsrch.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index 3a568c1c9933..501e965cb41b 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();
}