sw/qa/extras/uiwriter/data/tdf159054_disableOutlineNumbering.docx |binary sw/qa/extras/uiwriter/uiwriter9.cxx | 43 ++++++++++ sw/source/core/doc/docnum.cxx | 11 +- sw/source/uibase/shells/txtnum.cxx | 1 sw/source/uibase/wrtsh/wrtsh1.cxx | 31 ------- 5 files changed, 52 insertions(+), 34 deletions(-)
New commits: commit 5956bb9937164a815bccadd4801dee63c28367f5 Author: Justin Luth <[email protected]> AuthorDate: Mon Mar 18 16:56:55 2024 -0400 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Mar 21 10:54:23 2024 +0100 tdf#159054 sw: fix .uno:DefaultNumber toggle on Heading numbering This fixes a 7.2 regression from commit c456f839a597f537f1c59becd7d0bb6c86248ef8 Author: Anshu on Wed Jan 6 15:04:16 2021 +0530 tdf#115965 tdf#92622 NoList default in menu,tool,sidebar The current implementation would set the number format to SVX_NUM_NUMBER_NONE, but it still looks like a number to the toolbar, so toggling didn't work since 7.4's bcede3c0ed94d4 It also never cleared out the prefix/suffix when toggled off, and it affected ALL paragraphs using that outline numbering style. Remove numbering was doing the same kind of thing. I think the toggle was trying to follow the drop-down behaviour of modifying the outline numbering style itself. While I think the drop-down handling could be considered appropriate, using the toggle to pseudo-disable the entire style just seems wrong. This patch kills that, and in addition automatically gains all the nice undo/redo functionality. This is one tiny step in making outline numbering go away. make CppunitTest_sw_uiwriter9 \ CPPUNIT_TEST_NAME=testTdf159054_disableOutlineNumbering Change-Id: Id6a24ac25479cb8f35bf1c2c58344390ed7512fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164985 Reviewed-by: Justin Luth <[email protected]> Tested-by: Justin Luth <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165076 Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/qa/extras/uiwriter/data/tdf159054_disableOutlineNumbering.docx b/sw/qa/extras/uiwriter/data/tdf159054_disableOutlineNumbering.docx new file mode 100644 index 000000000000..091a3830e75b Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf159054_disableOutlineNumbering.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index 3772955dd9c1..96ea65e988d9 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -200,6 +200,49 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159816) xTransfer->PrivateDrop(*pWrtShell, ptTo, /*bMove=*/true, /*bXSelection=*/true); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159054_disableOutlineNumbering) +{ + createSwDoc("tdf159054_disableOutlineNumbering.docx"); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + const uno::Reference<text::XTextRange> xPara1 = getParagraph(1, "Heading A"); + const uno::Reference<text::XTextRange> xPara2 = getParagraph(2, "Heading B"); + const uno::Reference<text::XTextRange> xPara3 = getParagraph(3, "Heading C"); + + CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara1, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("B."), getProperty<OUString>(xPara2, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("C."), getProperty<OUString>(xPara3, "ListLabelString")); + + // select (at least parts) of the first two paragraphs + pWrtShell->Down(/*bSelect=*/true, /*nCount=*/1, /*bBasicCall=*/true); + + // on the selection, simulate pressing the toolbar button to toggle OFF numbering + dispatchCommand(mxComponent, ".uno:DefaultNumbering", {}); + + // the selected paragraphs should definitely have the list label removed + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara1, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara2, "ListLabelString")); + // the third paragraph must retain the existing numbering format + CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara3, "ListLabelString")); + + // on the selection, simulate pressing the toolbar button to toggle ON numbering again + dispatchCommand(mxComponent, ".uno:DefaultNumbering", {}); + + // the outline numbering format must be re-applied to the first two paragraphs + CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara1, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("B."), getProperty<OUString>(xPara2, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("C."), getProperty<OUString>(xPara3, "ListLabelString")); + + // on the selection, simulate a right click - list - No list + dispatchCommand(mxComponent, ".uno:RemoveBullets", {}); + + // the selected paragraphs should definitely have the list label removed + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara1, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara2, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara3, "ListLabelString")); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 0735380e5dc2..979107c919c5 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1368,10 +1368,15 @@ void SwDoc::DelNumRules(const SwPaM& rPam, SwRootFrame const*const pLayout) { pTNd->ChkCondColl(); } - else if( !pOutlNd && - static_cast<SwTextFormatColl*>(pTNd->GetFormatColl())->IsAssignedToListLevelOfOutlineStyle() ) + else { - pOutlNd = pTNd; + auto pParaStyle = static_cast<SwTextFormatColl*>(pTNd->GetFormatColl()); + if (pParaStyle && pParaStyle->IsAssignedToListLevelOfOutlineStyle()) + { + if (!pOutlNd) + pOutlNd = pTNd; + pTNd->SetCountedInList(false); + } } } } diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx index e769b7f46347..3283d5280675 100644 --- a/sw/source/uibase/shells/txtnum.cxx +++ b/sw/source/uibase/shells/txtnum.cxx @@ -111,7 +111,6 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) SfxRequest aReq(GetView().GetViewFrame(), FN_NUM_BULLET_ON); aReq.AppendItem(SfxBoolItem(FN_PARAM_1, false)); aReq.Done(); - GetShell().NumOrBulletOff(); GetShell().DelNumRules(); GetShell().EndAllAction(); } diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 0054eca4cb34..1e3b12b614ce 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1693,36 +1693,7 @@ void SwWrtShell::NumOrBulletOff() if (!pCurNumRule) return; - if (pCurNumRule->IsOutlineRule()) - { - SwNumRule aNumRule(*pCurNumRule); - - SwTextNode * pTextNode = - sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->GetNode()); - - if (pTextNode) - { - int nLevel = pTextNode->GetActualListLevel(); - - if (nLevel < 0) - nLevel = 0; - - if (nLevel >= MAXLEVEL) - nLevel = MAXLEVEL - 1; - - SwNumFormat aFormat(aNumRule.Get(o3tl::narrowing<sal_uInt16>(nLevel))); - - aFormat.SetNumberingType(SVX_NUM_NUMBER_NONE); - aNumRule.Set(nLevel, aFormat); - - // no start or continuation of a list - the outline style is only changed. - SetCurNumRule( aNumRule, false ); - } - } - else - { - DelNumRules(); - } + DelNumRules(); // #126346# - Cursor can not be anymore in front of // a label, because numbering/bullet is switched off.
