sw/qa/extras/uiwriter/data/tdf162326_list.odt |binary
 sw/qa/extras/uiwriter/uiwriter9.cxx           |  114 ++++++++++++++++++--------
 sw/source/core/doc/docfmt.cxx                 |    2 
 3 files changed, 83 insertions(+), 33 deletions(-)

New commits:
commit 675ab1f05af790dbcb7af7494469307a4f89f192
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Mon Nov 25 14:59:59 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Fri Nov 29 01:14:37 2024 +0100

    tdf#163870 remove list attribute on style apply
    
    Follow-up to 075560420a7aa238182e2d80dfe1c5fbaad3edbd
    Removes hard list attribute also if the applied paragraph
    style is applied again.
    
    Change-Id: Ic08241b5e244690825dfe79c419298c5d5f7c17e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177270
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177307
    Tested-by: allotropia jenkins <jenk...@allotropia.de>

diff --git a/sw/qa/extras/uiwriter/data/tdf162326_list.odt 
b/sw/qa/extras/uiwriter/data/tdf162326_list.odt
new file mode 100755
index 000000000000..324ac884337c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf162326_list.odt 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx 
b/sw/qa/extras/uiwriter/uiwriter9.cxx
index e0a1b49c1493..ec6e29db4061 100644
--- a/sw/qa/extras/uiwriter/uiwriter9.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter9.cxx
@@ -679,6 +679,88 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf144752)
     CPPUNIT_ASSERT_EQUAL(u"Word"_ustr, pWrtShell->GetSelText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162326_Paragraph)
+{
+    createSwDoc("tdf162326.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
+                         getProperty<float>(getRun(getParagraph(1), 1), 
u"CharWeight"_ustr));
+    CPPUNIT_ASSERT_EQUAL(
+        awt::FontSlant_ITALIC,
+        getProperty<awt::FontSlant>(getRun(getParagraph(2), 2), 
u"CharPosture"_ustr));
+    CPPUNIT_ASSERT_EQUAL(short(1),
+                         getProperty<short>(getRun(getParagraph(3), 2), 
u"CharUnderline"_ustr));
+
+    pWrtShell->Down(/*bSelect=*/true, 3);
+
+    dispatchCommand(mxComponent, u".uno:StyleApply"_ustr,
+                    { comphelper::makePropertyValue(u"FamilyName"_ustr, 
u"ParagraphStyles"_ustr),
+                      comphelper::makePropertyValue(u"Style"_ustr, 
u"Footnote"_ustr),
+                      comphelper::makePropertyValue(u"KeyModifier"_ustr, 
uno::Any(KEY_MOD1)) });
+
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL,
+                         getProperty<float>(getRun(getParagraph(1), 1), 
u"CharWeight"_ustr));
+    CPPUNIT_ASSERT_THROW(getRun(getParagraph(2), 2), 
css::container::NoSuchElementException);
+    CPPUNIT_ASSERT_THROW(getRun(getParagraph(3), 2), 
css::container::NoSuchElementException);
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162326_Character)
+{
+    createSwDoc("tdf162326.odt");
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
+                         getProperty<float>(getRun(getParagraph(1), 1), 
u"CharWeight"_ustr));
+    CPPUNIT_ASSERT_EQUAL(
+        awt::FontSlant_ITALIC,
+        getProperty<awt::FontSlant>(getRun(getParagraph(2), 2), 
u"CharPosture"_ustr));
+    CPPUNIT_ASSERT_EQUAL(short(1),
+                         getProperty<short>(getRun(getParagraph(3), 2), 
u"CharUnderline"_ustr));
+
+    pWrtShell->Down(/*bSelect=*/true, 3);
+
+    //add Ctrl/MOD_1
+    dispatchCommand(mxComponent, u".uno:StyleApply"_ustr,
+                    { comphelper::makePropertyValue(u"FamilyName"_ustr, 
u"CharacterStyles"_ustr),
+                      comphelper::makePropertyValue(u"Style"_ustr, 
u"Definition"_ustr),
+                      comphelper::makePropertyValue(u"KeyModifier"_ustr, 
uno::Any(KEY_MOD1)) });
+
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL,
+                         getProperty<float>(getRun(getParagraph(1), 1), 
u"CharWeight"_ustr));
+    CPPUNIT_ASSERT_THROW(getRun(getParagraph(2), 2), 
css::container::NoSuchElementException);
+    //last runs are not changed because the selection ends at the beginning of 
that paragraph
+    CPPUNIT_ASSERT_EQUAL(short(1),
+                         getProperty<short>(getRun(getParagraph(3), 2), 
u"CharUnderline"_ustr));
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162326_List)
+{
+    createSwDoc("tdf162326_list.odt");
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<text::XParagraphCursor> 
xParaCursor(xTextDocument->getText()->createTextCursor(),
+                                                       uno::UNO_QUERY);
+
+    CPPUNIT_ASSERT_EQUAL(u"A)"_ustr, getProperty<OUString>(xParaCursor, 
u"ListLabelString"_ustr));
+
+    dispatchCommand(mxComponent, u".uno:StyleApply"_ustr,
+                    { comphelper::makePropertyValue(u"FamilyName"_ustr, 
u"ParagraphStyles"_ustr),
+                      comphelper::makePropertyValue(u"Style"_ustr, 
u"Footnote"_ustr) });
+
+    //hard list attribute unchanged
+    CPPUNIT_ASSERT_EQUAL(u"A)"_ustr, getProperty<OUString>(xParaCursor, 
u"ListLabelString"_ustr));
+
+    dispatchCommand(mxComponent, u".uno:StyleApply"_ustr,
+                    { comphelper::makePropertyValue(u"FamilyName"_ustr, 
u"ParagraphStyles"_ustr),
+                      comphelper::makePropertyValue(u"Style"_ustr, 
u"Footnote"_ustr),
+                      comphelper::makePropertyValue(u"KeyModifier"_ustr, 
uno::Any(KEY_MOD1)) });
+
+    //list replaced by para style list setting
+    CPPUNIT_ASSERT_EQUAL(u"1."_ustr, getProperty<OUString>(xParaCursor, 
u"ListLabelString"_ustr));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf163340)
 {
     createSwDoc("tdf163340.odt");
@@ -737,38 +819,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, 
testTdf162326_Pargraph)
     CPPUNIT_ASSERT_THROW(getRun(getParagraph(3), 2), 
css::container::NoSuchElementException);
 }
 
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162326_Character)
-{
-    createSwDoc("tdf162326.odt");
-    SwXTextDocument* pDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pDoc);
-    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
-    CPPUNIT_ASSERT(pWrtShell);
-
-    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD,
-                         getProperty<float>(getRun(getParagraph(1), 1), 
u"CharWeight"_ustr));
-    CPPUNIT_ASSERT_EQUAL(
-        awt::FontSlant_ITALIC,
-        getProperty<awt::FontSlant>(getRun(getParagraph(2), 2), 
u"CharPosture"_ustr));
-    CPPUNIT_ASSERT_EQUAL(short(1),
-                         getProperty<short>(getRun(getParagraph(3), 2), 
u"CharUnderline"_ustr));
-
-    pWrtShell->Down(/*bSelect=*/true, 3);
-
-    //add Ctrl/MOD_1
-    dispatchCommand(mxComponent, u".uno:StyleApply"_ustr,
-                    { comphelper::makePropertyValue(u"FamilyName"_ustr, 
u"CharacterStyles"_ustr),
-                      comphelper::makePropertyValue(u"Style"_ustr, 
u"Definition"_ustr),
-                      comphelper::makePropertyValue(u"KeyModifier"_ustr, 
uno::Any(KEY_MOD1)) });
-
-    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL,
-                         getProperty<float>(getRun(getParagraph(1), 1), 
u"CharWeight"_ustr));
-    CPPUNIT_ASSERT_THROW(getRun(getParagraph(2), 2), 
css::container::NoSuchElementException);
-    //last runs are not changed because the selection ends at the beginning of 
that paragraph
-    CPPUNIT_ASSERT_EQUAL(short(1),
-                         getProperty<short>(getRun(getParagraph(3), 2), 
u"CharUnderline"_ustr));
-}
-
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162195)
 {
     // Given a document, which has some index entries in a hidden section
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 3a1da208a6d6..abce04888365 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1044,7 +1044,7 @@ static bool lcl_SetTextFormatColl( SwNode* pNode, void* 
pArgs )
 
         // #i62675# check, if paragraph style has changed
         if ( pPara->bResetListAttrs &&
-             pFormat != pCNd->GetFormatColl()
+             (pPara->bResetAllCharAttrs || pFormat != pCNd->GetFormatColl())
             && pCNd->GetTextNode()->IsInList() )
         {
             // Check, if the list style of the paragraph will change.

Reply via email to