sw/qa/extras/uiwriter/data/tdf113213_addToList.odt |binary sw/qa/extras/uiwriter/uiwriter11.cxx | 18 +++++++++++++++++ sw/source/core/edit/ednumber.cxx | 2 - sw/source/uibase/shells/textsh1.cxx | 22 +++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-)
New commits: commit fba33149f74eae5aaa02d70b93be116d865b1092 Author: Justin Luth <jl...@mail.com> AuthorDate: Wed Sep 24 13:55:37 2025 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Fri Sep 26 00:43:58 2025 +0200 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. make CppunitTest_sw_uiwriter11 \ CPPUNIT_TEST_NAME=testTdf113213_addToList Change-Id: I3bc78dceea6b95869d7c0742eed0eda126392588 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117660 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/uiwriter/data/tdf113213_addToList.odt b/sw/qa/extras/uiwriter/data/tdf113213_addToList.odt new file mode 100644 index 000000000000..e774cde970f3 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113213_addToList.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter11.cxx b/sw/qa/extras/uiwriter/uiwriter11.cxx index c2814473de90..5e4d2b10e5b9 100644 --- a/sw/qa/extras/uiwriter/uiwriter11.cxx +++ b/sw/qa/extras/uiwriter/uiwriter11.cxx @@ -70,6 +70,24 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf167760_numberedPara) CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(1), "ListLabelString")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf113213_addToList) +{ + // given a document with two separate numbering lists + createSwDoc("tdf113213_addToList.odt"); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + + // Select the second list + pWrtShell->EndOfSection(); + pWrtShell->Up(/*bSelect=*/true); + // "Add to list": join the second list to the previous one + dispatchCommand(mxComponent, u".uno:ContinueNumbering"_ustr, {}); + // The "restart numbering" property should be helpfully removed when joining to another list + CPPUNIT_ASSERT_EQUAL(OUString("3"), getProperty<OUString>(getParagraph(6), "ListLabelString")); + + pWrtShell->Undo(); + CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(getParagraph(6), "ListLabelString")); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791) { auto getPostItMgr = [](SwDocShell* pDocShell) { diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index e27e14fe2df4..19df3a47a923 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1873,7 +1873,29 @@ void SwTextShell::Execute(SfxRequest &rReq) } if ( pRule ) { + rWrtSh.StartUndo(SwUndoId::INSATTR); + + // When merging with a different list, also helpfully remove any restart-numbering + if (!rReq.IsAPI()) // no need to be "helpful" like this for a macro + { + for(SwPaM& rPaM : rWrtSh.GetCursor()->GetRingContainer()) + { + // check each selected paragraph separately + const SwNodeIndex nEnd = rPaM.End()->nNode; + for (SwNodeIndex nPara = rPaM.Start()->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.Start(), rWrtSh.GetLayout()) != pRule) + rWrtSh.SetNumRuleStart(false, &aPaM); + } + } + } + rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId ); + rWrtSh.EndUndo(SwUndoId::INSATTR); } } break; commit 2f859c4673ab876c387957db74ed8c6c3c6d7493 Author: Justin Luth <jl...@mail.com> AuthorDate: Wed Sep 24 12:20:22 2025 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Fri Sep 26 00:43:50 2025 +0200 related tdf#113213 SetNumRuleStart: don't GetCursor when PaM provided Just look at the function. It indicates is should only use GetCursor if no PaM was provided, so why should the call be based on the current cursor position if it wasn't a MultiSelection? None of the other related functions use this broken logic... Actually, this looks like a typo regression from 6.2 commit 4d472b9b80a5c62338b7f080d5654d741c75e532 Author: Michael Stahl on Fri Oct 26 17:20:17 2018 +0200 sw_redlinehide_3: adapt more SwEditShell Num Change-Id: I71719a866a7ffcdcb4c91c1fe8b4e44ff0b4fb68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191457 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index e9f66c98f73c..e0fc1c7cbbd1 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -815,7 +815,7 @@ void SwEditShell::SetNumRuleStart( bool bFlag, SwPaM* pPaM ) } else { - SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *GetCursor()->GetPoint())); + SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *pCursor->GetPoint())); GetDoc()->SetNumRuleStart(pos, bFlag); }