summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-08-25 00:39:21 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-08-27 07:22:14 +0000
commit546f1a008482ca5227897faaf4e588a7d8f5dd58 (patch)
treea8e3851175a34aa5bbd99dbdc3c7328aa2b5be43 /sw
parent4ba96f77df9c3e04c674a655807e1686670da5f1 (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 (cherry picked from commit b3233579ccb2528912835deedde37c1d48417d6c) Reviewed-on: https://gerrit.libreoffice.org/481 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sw')
-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 d0f6079f917a..1e583ce71d0d 100644
--- a/sw/source/ui/uiview/viewsrch.cxx
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -286,36 +286,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();
}