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 67eec140556edb42280def88e987448aaa221c5e
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Jun 10 18:25:05 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jun 14 21:28:47 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>
    (cherry picked from commit d72bee64a97650507d042f17846b6fc427b8434c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135839
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 41ef84d1d00f..a4ba598df693 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -282,7 +282,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 96ea6f56816d..6a43d8841e59 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -292,7 +292,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
@@ -319,7 +319,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 c6dee2be2ec6..3fb293405387 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -245,7 +245,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();
@@ -1791,7 +1792,7 @@ void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, 
sal_Unicode cChar )
 
         StartUndo( SwUndoId::REPLACE, &aRewriter );
         bStarted = true;
-        DelRight();
+        DelRight(true);
     }
     SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar );
 

Reply via email to