sw/inc/editsh.hxx              |    2 +-
 sw/inc/swtypes.hxx             |    3 ++-
 sw/source/core/edit/edfcol.cxx |    8 ++++----
 sw/source/uibase/app/docst.cxx |   10 +++++-----
 4 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 1dbab9fe00e6fd0b1fa881fabcac2488ade00a37
Author:     Justin Luth <[email protected]>
AuthorDate: Wed Aug 27 15:45:58 2025 -0400
Commit:     Justin Luth <[email protected]>
CommitDate: Mon Sep 1 15:56:11 2025 +0200

    related tdf#162326: fix missed bResetListAttrs when bResetAllCharAttrs
    
    Although more flexible,
    there was no need to pass a SetAttrMode to SetTextFormatColl,
    and it introduced a situation
    where bResetListAttrs was NOT forced to true
    despite what REMOVE_ALL_ATTRS (should have) documented
    after commit 075560420a7aa238182e2d80dfe1c5fbaad3edbd.
    
    Instead of choosing to set bRestListAttrs |= bResetAllCharAttrs
    I decided to simply pass in a boolean instead.
    Everything is much more readable that way.
    
    Change-Id: I4aaeeee2256dd2cdefc962682067f51ca26de253
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190311
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index b78e16336ba7..f66ede9d56e2 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -339,7 +339,7 @@ public:
     /// Add 2nd optional parameter <bResetListAttrs> - see also 
<SwDoc::SetTextFormatColl(..)>
     SW_DLLPUBLIC void SetTextFormatColl(SwTextFormatColl*,
         const bool bResetListAttrs = false,
-        SetAttrMode nMode = SetAttrMode::DEFAULT);
+        const bool bResetAllCharAttrs = false);
     SW_DLLPUBLIC SwTextFormatColl *MakeTextFormatColl(const UIName 
&rFormatCollName,
         SwTextFormatColl *pDerivedFrom = nullptr);
     void FillByEx(SwTextFormatColl*);
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index 8f61ef20a63a..a6e54c491e9c 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -153,7 +153,8 @@ enum class SetAttrMode
     NOHINTEXPAND    = 0x0100,
     /// don't change the cursor position
     NO_CURSOR_CHANGE = 0x0200,
-    // remove all char attributes and char styles when para/char styles are 
applied
+    /// remove all char attributes and char styles when para/char styles are 
applied
+    /// as well as removing list attributes (when para styles are applied)
     REMOVE_ALL_ATTR = 0x0400
 };
 namespace o3tl
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index c18893a9ee8b..fc4bb02073ee 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -2204,9 +2204,8 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass()
 }
 
 // #i62675#
-void SwEditShell::SetTextFormatColl(SwTextFormatColl *pFormat,
-                                const bool bResetListAttrs,
-                                SetAttrMode nMode)
+void SwEditShell::SetTextFormatColl(SwTextFormatColl *pFormat, const bool 
bResetListAttrs,
+                                    const bool bResetAllCharAttrs)
 {
     SwTextFormatColl *pLocal = pFormat? pFormat: 
(*GetDoc()->GetTextFormatColls())[0];
     StartAllAction();
@@ -2236,7 +2235,8 @@ void SwEditShell::SetTextFormatColl(SwTextFormatColl 
*pFormat,
             }
 
             // Change the paragraph style to pLocal and remove all direct 
paragraph formatting.
-            GetDoc()->SetTextFormatColl(rPaM, pLocal, true, bResetListAttrs, 
!!(nMode & SetAttrMode::REMOVE_ALL_ATTR), GetLayout());
+            GetDoc()->SetTextFormatColl(rPaM, pLocal, true, bResetListAttrs, 
bResetAllCharAttrs,
+                                        GetLayout());
 
             // If there are hints on the nodes which cover the whole node, 
then remove those, too.
             SwPaM aPaM(*rPaM.Start(), *rPaM.End());
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 37f3d8a35220..989eeaa871ec 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1221,7 +1221,8 @@ bool SwDocShell::MakeInlineHeading(SwWrtShell *pSh, 
SwTextFormatColl* pColl, con
             pSh->MoveSection( GoCurrSection, fnSectionEnd );
             pSh->SelAll();
 
-            pSh->SetTextFormatColl( pColl, true, (nMode & KEY_MOD1) ? 
SetAttrMode::REMOVE_ALL_ATTR : SetAttrMode::DEFAULT);
+            const bool bResetAllCharAttrs(nMode & KEY_MOD1);
+            pSh->SetTextFormatColl(pColl, true, bResetAllCharAttrs);
 
             // zero the upper and lower margins of the paragraph (also an 
interoperability issue)
             SfxItemSetFixed<RES_UL_SPACE, RES_UL_SPACE> 
aSet2(pSh->GetAttrPool());
@@ -1292,12 +1293,11 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString 
&rName, SfxStyleFamily nFa
                 // #i62675#
                 // clear also list attributes at affected text nodes, if 
paragraph
                 // style has the list style attribute set.
-                const SetAttrMode nAttrModeFlag
-                    = (nMode & KEY_MOD1) ? SetAttrMode::REMOVE_ALL_ATTR : 
SetAttrMode::DEFAULT;
+                const bool bResetAllCharAttrs(nMode & KEY_MOD1);
                 const bool bResetListAttrs
-                    = nAttrModeFlag == SetAttrMode::REMOVE_ALL_ATTR
+                    = bResetAllCharAttrs
                       || (pColl && pColl->GetItemState(RES_PARATR_NUMRULE) == 
SfxItemState::SET);
-                pSh->SetTextFormatColl(pColl, bResetListAttrs, nAttrModeFlag);
+                pSh->SetTextFormatColl(pColl, bResetListAttrs, 
bResetAllCharAttrs);
             }
             break;
         }

Reply via email to