sw/qa/extras/uiwriter/data/tdf159054_disableOutlineNumbering.docx |binary sw/qa/extras/uiwriter/uiwriter9.cxx | 37 ++++++++++ 2 files changed, 37 insertions(+)
New commits: commit f78c0dfa7a63303533eed17636e7abf8332eea48 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon Mar 18 16:56:55 2024 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Mar 20 16:19:14 2024 +0100 tdf#159054 unit test: noting the current state before making changes The historical implementation is rather bizarre, so I submit it beforehand so that my patch shows the changes in behaviour in a clearer way. I checked LO 5.1, and while things were slightly different (still inexplicable, but not in the same way) it still did leave behind the suffix, and toggled back on as 1. So this has never been good. Throwing out the old behaviour seems appropriate in this case. make CppunitTest_sw_uiwriter9 \ CPPUNIT_TEST_NAME=testTdf159054_disableOutlineNumbering Change-Id: Id794e629d00480bc5a031aaf0595084cb3eb3559 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164984 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> 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 77245e63ce2f..a18f14c9ad9a 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -408,6 +408,43 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf151710) CPPUNIT_ASSERT_EQUAL(sStartDoubleQuote, pTextDoc->getText()->getString()); } +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")); + // current implementation: the numbering style itself is changed too - affects all Heading 1's. + // A valid alternative implementation would be to simply SetCountInList(false) for 1st para, + // and leave the Outline style format alone. + CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara3, "ListLabelString")); + + // on the selection, simulate pressing the toolbar button to toggle ON numbering again + dispatchCommand(mxComponent, ".uno:DefaultNumbering", {}); + + // current implementation: the entire format was removed, so turn (default) numbering on + CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara1, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara2, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara3, "ListLabelString")); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf158375_dde_disable) { std::shared_ptr<comphelper::ConfigurationChanges> pBatch(