summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-08-25 00:39:21 +0200
committerMichael Stahl <mstahl@redhat.com>2012-08-25 01:17:07 +0200
commitb3233579ccb2528912835deedde37c1d48417d6c (patch)
treea4000157b522bde563493deb10fa0a88ffbb9f9a
parentd52a1320dbe142d2fc184e031bf79994f5ef1144 (diff)
fdo#49901: SwView::ExecSearch: fix Replace All cursor:
Because the "fix" for i#8288 only set the point of the cursor and not the mark, it can happen that after a Replace All weird things are selected; fix that (and i#8288 properly) by using the SwCrsrShell stack, and don't do it when searching in the selection. This cannot be done in SwCrsrShell itself because ExecSearch sets the cursor to the beginning/end of the document already. (regression from cda75d6f358d438f7ed36ed7fa296ac23e3c4a04) Change-Id: Ie9f8d7da2fa26000a0237c24f8742e47ffa29213
-rw-r--r--sw/source/ui/uiview/viewsrch.cxx46
1 files changed, 23 insertions, 23 deletions
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index bb8d438953bd..3dfbd450c838 100644
--- a/sw/source/ui/uiview/viewsrch.cxx
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -282,36 +282,36 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
case SVX_SEARCHCMD_REPLACE_ALL:
{
SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
-
- // 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() )
- {
- // bestehende Selektionen aufheben,
- // wenn nicht in selektierten Bereichen gesucht werden soll
- pWrtShell->KillSelection(0, false);
- if( DOCPOS_START == aOpts.eEnd )
- pWrtShell->EndDoc();
- else
- pWrtShell->SttDoc();
- }
-
bExtra = sal_False;
sal_uLong nFound;
{ //Scope for SwWait-Object
SwWait aWait( *GetDocShell(), sal_True );
pWrtShell->StartAllAction();
+ if (!pSrchItem->GetSelection())
+ {
+ // if we don't want to search in the selection...
+ pWrtShell->KillSelection(0, false);
+ // i#8288 "replace all" should not change cursor
+ // position, so save current cursor
+ pWrtShell->Push();
+ if (DOCPOS_START == aOpts.eEnd)
+ {
+ pWrtShell->EndDoc();
+ }
+ else
+ {
+ pWrtShell->SttDoc();
+ }
+ }
nFound = FUNC_Search( aOpts );
- // #i8288# Now that everything has been replaced, restore the original cursor position.
- *(pWrtShell->GetSwCrsr()->GetPoint()) =
- *pTmpCursor->GetPoint();
+ if (!pSrchItem->GetSelection())
+ {
+ // create it just to overwrite it with stack cursor
+ pWrtShell->CreateCrsr();
+ // i#8288 restore the original cursor position
+ pWrtShell->Pop(false);
+ }
pWrtShell->EndAllAction();
}