Kaydet (Commit) b3233579 authored tarafından Michael Stahl's avatar Michael Stahl

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 cda75d6f)

Change-Id: Ie9f8d7da2fa26000a0237c24f8742e47ffa29213
üst d52a1320
...@@ -282,36 +282,36 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage) ...@@ -282,36 +282,36 @@ void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
case SVX_SEARCHCMD_REPLACE_ALL: case SVX_SEARCHCMD_REPLACE_ALL:
{ {
SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() ); 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; bExtra = sal_False;
sal_uLong nFound; sal_uLong nFound;
{ //Scope for SwWait-Object { //Scope for SwWait-Object
SwWait aWait( *GetDocShell(), sal_True ); SwWait aWait( *GetDocShell(), sal_True );
pWrtShell->StartAllAction(); 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 ); nFound = FUNC_Search( aOpts );
// #i8288# Now that everything has been replaced, restore the original cursor position. if (!pSrchItem->GetSelection())
*(pWrtShell->GetSwCrsr()->GetPoint()) = {
*pTmpCursor->GetPoint(); // create it just to overwrite it with stack cursor
pWrtShell->CreateCrsr();
// i#8288 restore the original cursor position
pWrtShell->Pop(false);
}
pWrtShell->EndAllAction(); pWrtShell->EndAllAction();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment