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 eda9d88054423025c97d07136e7ff77789b17857 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Jan 18 14:56:54 2024 +0600 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Apr 11 08:38:51 2024 +0200 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. (cherry picked from commit c80606bb23fd42e41710d70a96b7ffaf948384a6) Change-Id: I9cb7af235a066bea2c7b21b8ff515dcdd52218c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165335 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit ccb26c80cb9f8da9ad6a4d1874a8e68215284eef) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165848 diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 663a0ffc35f7..604e9ac91aab 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -151,7 +151,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 ); @@ -173,7 +173,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 6cbce339615c..0ccc93f6154e 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -31,7 +31,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() @@ -125,11 +126,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; @@ -148,7 +150,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 ad49d66e58bf..44b9afe5ae92 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -169,7 +169,7 @@ bool SwWrtShell::DelLeft() { SwActContext aActContext(this); ResetCursorStack(); - Delete(false); + Delete(false, true); UpdateAttr(); } if( IsBlockMode() ) @@ -277,7 +277,7 @@ bool SwWrtShell::DelLeft() } } } - bool bRet = Delete(true); + bool bRet = Delete(true, true); if( !bRet && bSwap ) SwCursorShell::SwapPam(); CloseMark( bRet );