sw/inc/editsh.hxx                 |    4 ++--
 sw/source/core/edit/eddel.cxx     |    8 +++++---
 sw/source/uibase/wrtsh/delete.cxx |    4 ++--
 3 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit c80606bb23fd42e41710d70a96b7ffaf948384a6
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jan 18 14:56:54 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Jan 18 14:14:06 2024 +0100

    tdf#109272: make sure that Delete / Backspace move cursor correctly
    
    ... in change tracking mode. Cursor's end position now doesn't depend
    on the selection direction; it is at the deletion's beginning in case
    of Backspace, and at deletion's end in case of Delete.
    
    Change-Id: I9cb7af235a066bea2c7b21b8ff515dcdd52218c6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162240
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 1fb9ff3a5bae..2b753530159a 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -152,7 +152,7 @@ class SW_DLLPUBLIC SwEditShell : public SwCursorShell
      that will be used by GetGraphic() and GetGraphicSize(). */
     SAL_DLLPRIVATE SwGrfNode *GetGrfNode_() const ;
 
-    SAL_DLLPRIVATE void DeleteSel(SwPaM& rPam, bool isArtificialSelection, 
bool* pUndo = nullptr);
+    SAL_DLLPRIVATE void DeleteSel(SwPaM& rPam, bool isArtificialSelection, 
bool goLeft = false, bool* pUndo = nullptr);
 
     SAL_DLLPRIVATE void SetSectionAttr_( SwSectionFormat& rSectFormat, const 
SfxItemSet& rSet );
 
@@ -178,7 +178,7 @@ public:
 
     /** Delete content of all ranges.
      If whole nodes are selected, these nodes get deleted. */
-    bool Delete(bool isArtificialSelection = false);
+    bool Delete(bool isArtificialSelection = false, bool goLeft = false);
 
     /// Remove a complete paragraph.
     bool DelFullPara();
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 9eb51da617b1..b8d6b0e39554 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -33,7 +33,8 @@
 #include <strings.hrc>
 #include <vector>
 
-void SwEditShell::DeleteSel(SwPaM& rPam, bool const isArtificialSelection, 
bool *const pUndo)
+void SwEditShell::DeleteSel(SwPaM& rPam, bool const isArtificialSelection, 
bool goLeft,
+                            bool* const pUndo)
 {
     auto const oSelectAll(StartsWith_() != SwCursorShell::StartsWith::None
         ? ExtendedSelectedAll()
@@ -127,11 +128,12 @@ void SwEditShell::DeleteSel(SwPaM& rPam, bool const 
isArtificialSelection, bool
         }
     }
 
+    rPam.Normalize(goLeft); // change tracking case: will make sure to end up 
in the correct point
     // Selection is not needed anymore
     rPam.DeleteMark();
 }
 
-bool SwEditShell::Delete(bool const isArtificialSelection)
+bool SwEditShell::Delete(bool const isArtificialSelection, bool goLeft)
 {
     CurrShell aCurr( this );
     bool bRet = false;
@@ -159,7 +161,7 @@ bool SwEditShell::Delete(bool const isArtificialSelection)
 
         for(SwPaM& rPaM : GetCursor()->GetRingContainer())
         {
-            DeleteSel(rPaM, isArtificialSelection, &bUndo);
+            DeleteSel(rPaM, isArtificialSelection, goLeft, &bUndo);
         }
 
         // If undo container then close here
diff --git a/sw/source/uibase/wrtsh/delete.cxx 
b/sw/source/uibase/wrtsh/delete.cxx
index e7a09d016587..46b0a40cca5d 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -171,7 +171,7 @@ bool SwWrtShell::DelLeft()
             {
                 SwActContext aActContext(this);
                 ResetCursorStack();
-                Delete(false);
+                Delete(false, true);
                 UpdateAttr();
             }
             if( IsBlockMode() )
@@ -274,7 +274,7 @@ bool SwWrtShell::DelLeft()
             SwCursorShell::Pop( SwCursorShell::PopMode::DeleteStack );
         }
     }
-    bool bRet = Delete(true);
+    bool bRet = Delete(true, true);
     if( !bRet && bSwap )
         SwCursorShell::SwapPam();
     CloseMark( bRet );

Reply via email to