sw/source/uibase/inc/wrtsh.hxx | 2 +- sw/source/uibase/wrtsh/delete.cxx | 4 ++-- sw/source/uibase/wrtsh/wrtsh1.cxx | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-)
New commits: commit d72bee64a97650507d042f17846b6fc427b8434c Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Jun 10 18:25:05 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jun 14 13:29:16 2022 +0200 tdf#148868 sw: handle selection then Insert similar to Replace ... if the selection is inside one paragraph, to avoid deleting flys anchored in the selection. From a code point of view it's a bit inconsistent to do this, but from user point of view there are some ways to conveniently create a selection such as by double clicking a word. (see also tdf#133957) Also in SwWrtShell::AutoCorrect(), which oddly enough might get called with a selection from textsh*.cxx, at least in theory. Change-Id: I8cf9459e5a7ec7754ce8fe323cd158c7e84a5c93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135606 Tested-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx index 91cb72146fc0..134c7dc5dbf6 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -285,7 +285,7 @@ typedef bool (SwWrtShell::*FNSimpleMove)(); bool DelLeft(); // also deletes the frame or sets the cursor in the frame when bDelFrame == false - bool DelRight(); + bool DelRight(bool isReplaceHeuristic = false); void DelToEndOfPara(); void DelToStartOfPara(); bool DelToEndOfSentence(); diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index 5a1a1b031675..80eda5292b5e 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -291,7 +291,7 @@ bool SwWrtShell::DelLeft() return bRet; } -bool SwWrtShell::DelRight() +bool SwWrtShell::DelRight(bool const isReplaceHeuristic) { // Will be or'ed, if a tableselection exists; // will here be implemented on SelectionType::Table @@ -318,7 +318,7 @@ bool SwWrtShell::DelRight() { SwActContext aActContext(this); ResetCursorStack(); - Delete(false); + Delete(isReplaceHeuristic); UpdateAttr(); } if( IsBlockMode() ) diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 4940e24cf24b..ee6ae421be93 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -251,7 +251,8 @@ void SwWrtShell::Insert( const OUString &rStr ) StartUndo(SwUndoId::REPLACE, &aRewriter); bStarted = true; Push(); - bDeleted = DelRight(); + // let's interpret a selection within the same node as "replace" + bDeleted = DelRight(GetCursor()->GetPoint()->nNode == GetCursor()->GetMark()->nNode); Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore selection (if tracking changes) NormalizePam(false); // tdf#127635 put point at the end of deletion ClearMark(); @@ -1948,7 +1949,7 @@ void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar ) StartUndo( SwUndoId::REPLACE, &aRewriter ); bStarted = true; - DelRight(); + DelRight(true); } SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar );