From 507979255fb86497918712a47e8c114f9d3aa5cf Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 22 Jun 2021 14:42:23 +0200 Subject: [PATCH] tdf#113213 sw UI: clear restart numbering when add-to-list When you join a different list to the prior list in the document, it is extremely likely that you do not want the numbering to restart. That restart belonged to the old list, and isn't expected to remain when changing to join a different list. Change-Id: I3bc78dceea6b95869d7c0742eed0eda126392588 --- diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 0c11a93..d595895 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -1124,6 +1125,27 @@ } if ( pRule ) { + // When merging with a different list, also remove any restart-numbering. + const SwPaM& rCursor = *rWrtSh.GetCursor(); + // if IsMultiSelection - check each selected paragraph separately. + SwPamRanges aRangeArr(rCursor); + SwPaM aRingPaM(*rCursor.GetPoint()); + for (size_t n = 0; n < aRangeArr.Count(); ++n) + { + aRangeArr.SetPam(n, aRingPaM); + aRingPaM.Normalize(); + const SwNodeIndex nEnd = aRingPaM.GetMark()->nNode; + for (SwNodeIndex nPara = aRingPaM.GetPoint()->nNode; nPara <= nEnd; ++nPara) + { + SwPaM aPaM(nPara); + if (!rWrtSh.IsNumRuleStart(&aPaM)) + continue; + // Only remove restart-numbering if the rule is actually going to change. + if (SwDoc::GetNumRuleAtPos(*aPaM.GetPoint(), rWrtSh.GetLayout()) != pRule) + rWrtSh.SetNumRuleStart(false, &aPaM); + } + } + rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId ); } }