From c1cfe85f8bba10d367ef9ef1d6d569f53969dd34 Mon Sep 17 00:00:00 2001 From: luigiiucci Date: Thu, 15 Jun 2023 23:31:26 +0200 Subject: tdf#62032 use style list level when changing style If a style S1 has a list level L1, and we change the style to S1 in a text node that has list level L2, the new text node list level must be L1 Change-Id: Ic25b222202cb2da3153fc5c3723998c9f7f01247 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153161 Reviewed-by: Ashod Nakashian Tested-by: Jenkins --- .../extras/uiwriter/data/tdf62032_apply_style.odt | Bin 0 -> 10951 bytes sw/qa/extras/uiwriter/uiwriter8.cxx | 21 +++++++++++++++++++++ sw/source/core/doc/docfmt.cxx | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 sw/qa/extras/uiwriter/data/tdf62032_apply_style.odt (limited to 'sw') diff --git a/sw/qa/extras/uiwriter/data/tdf62032_apply_style.odt b/sw/qa/extras/uiwriter/data/tdf62032_apply_style.odt new file mode 100644 index 000000000000..86cda167ee8a Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf62032_apply_style.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 28eaf3e9f1b0..48b17ef211ea 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -2653,6 +2653,27 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf73483) assertXPath(pXml, para_style_path, "master-page-name", "Right_20_Page"); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf62032ApplyStyle) +{ + createSwDoc("tdf62032_apply_style.odt"); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtSh = pDoc->GetDocShell()->GetWrtShell(); + + pWrtSh->Down(/*bSelect=*/false); + + uno::Sequence aPropertyValues = comphelper::InitPropertySequence({ + { "Style", uno::Any(OUString("A 2")) }, + { "FamilyName", uno::Any(OUString("ParagraphStyles")) }, + }); + dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues); + + // Without the fix in place, it fails with: + // - Expected: 1.1 + // - Actual : 2 + CPPUNIT_ASSERT_EQUAL(OUString("1.1"), + getProperty(getParagraph(2), "ListLabelString").trim()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 655925f434ae..3f52628fed21 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1072,6 +1072,11 @@ static bool lcl_SetTextFormatColl( SwNode* pNode, void* pArgs ) pCNd->ResetAttr( RES_PARATR_LIST_ISCOUNTED ); pCNd->ResetAttr( RES_PARATR_LIST_ID ); } + else + { + // forcing reset of list level from parapgaph + pCNd->SetAttr(pFormat->GetFormatAttr(RES_PARATR_LIST_LEVEL)); + } } } -- cgit