Kaydet (Commit) 5b8e7ef7 authored tarafından Caolán McNamara's avatar Caolán McNamara

drop apparent optimization to handle regexp's the same way

üst 19a13008
......@@ -594,51 +594,41 @@ void SwView::Replace()
if(pWrtShell->HasSelection())
{
/* check that the selection has the same length as the required string */
if (pWrtShell->SwCrsrShell::GetSelTxt().Len() != pSrchItem->GetSearchString().Len() )
/* check that the selection match the search string*/
//save state
SwPosition aStartPos = (* pWrtShell->GetSwCrsr()->Start());
SwPosition aEndPos = (* pWrtShell->GetSwCrsr()->End());
sal_Bool bHasSelection = pSrchItem->GetSelection();
sal_uInt16 nOldCmd = pSrchItem->GetCommand();
//set state for checking if current selection has a match
pSrchItem->SetCommand( SVX_SEARCHCMD_FIND );
pSrchItem->SetSelection(true);
//check if it matchs
SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
if( ! FUNC_Search(aOpts) )
{
//it differs, therefore do not replace the selection
bReqReplace = false;
//next call to replace will find the next matching string
}
else
{
/* check that the selection match the search string*/
//save state
SwPosition aStartPos = (* pWrtShell->GetSwCrsr()->Start());
SwPosition aEndPos = (* pWrtShell->GetSwCrsr()->End());
sal_Bool bHasSelection = pSrchItem->GetSelection();
sal_uInt16 nOldCmd = pSrchItem->GetCommand();
//set state for checking if current selection has a match
pSrchItem->SetCommand( SVX_SEARCHCMD_FIND );
pSrchItem->SetSelection(true);
//check if it matchs
SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
if( ! FUNC_Search(aOpts) )
{
//no matching therefore should not replace selection
// => remove selection
//no matching therefore should not replace selection
// => remove selection
if(! pSrchItem->GetBackward() )
{
(* pWrtShell->GetSwCrsr()->Start()) = aStartPos;
(* pWrtShell->GetSwCrsr()->End()) = aEndPos;
}
else
{
(* pWrtShell->GetSwCrsr()->Start()) = aEndPos;
(* pWrtShell->GetSwCrsr()->End()) = aStartPos;
}
bReqReplace = false;
if(! pSrchItem->GetBackward() )
{
(* pWrtShell->GetSwCrsr()->Start()) = aStartPos;
(* pWrtShell->GetSwCrsr()->End()) = aEndPos;
}
//set back old search state
pSrchItem->SetCommand( nOldCmd );
pSrchItem->SetSelection(bHasSelection);
else
{
(* pWrtShell->GetSwCrsr()->Start()) = aEndPos;
(* pWrtShell->GetSwCrsr()->End()) = aStartPos;
}
bReqReplace = false;
}
//set back old search state
pSrchItem->SetCommand( nOldCmd );
pSrchItem->SetSelection(bHasSelection);
}
/*
* remove current selection
......
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