sw/qa/extras/uiwriter/data/tdf62032_apply_style.odt |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx                 |   21 ++++++++++++++++++++
 sw/source/core/doc/docfmt.cxx                       |    5 ++++
 3 files changed, 26 insertions(+)

New commits:
commit c1cfe85f8bba10d367ef9ef1d6d569f53969dd34
Author:     luigiiucci <luigi.iu...@collabora.com>
AuthorDate: Thu Jun 15 23:31:26 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jul 10 08:18:51 2023 +0200

    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 <a...@collabora.com>
    Tested-by: Jenkins

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<beans::PropertyValue> 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<OUString>(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));
+            }
         }
     }
 

Reply via email to