[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Aug 27 00:22:50 PDT 2012
sw/source/ui/uiview/viewsrch.cxx | 46 +++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 23 deletions(-)
New commits:
commit 546f1a008482ca5227897faaf4e588a7d8f5dd58
Author: Michael Stahl <mstahl at redhat.com>
Date: Sat Aug 25 00:39:21 2012 +0200
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 at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index d0f6079..1e583ce 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();
}
More information about the Libreoffice-commits
mailing list