sw/source/core/edit/autofmt.cxx |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 0da3a5dc1101d1b8a8257f8b04aca8046ca201f2
Author:     Michael Stahl <[email protected]>
AuthorDate: Tue Dec 16 15:38:11 2025 +0100
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Wed Dec 17 01:56:47 2025 +0100

    sw: fix AutoFormat applying TextBody style
    
    The problem is that BuildText() applies the "Text body" style, and it's
    now called even in the !m_aFlags.bAFormatByInput case (previously
    it (or other Build* functions that also set styles) was only called when
    the user runs the AutoFormat menu item).
    
    Not calling it at all lets the testTdf139922 fail, as it also calls
    AutoCorrect(), which this test checks.
    
    So let's try 2 things:
    1. only call BuildText when it's explicit AutoFormat
    2. skip setting the text body style if the new config that was introduced
       by the same commit is disabled.
    
    (regression from commit 5bd1efb830400e1394d45f122faf7537e4451f33)
    
    Change-Id: Ib7d0bad479fe52c013a1b70633de7cb01db047f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195733
    Tested-by: allotropia jenkins <[email protected]>
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 2deafb5a5d35..1b799e02a760 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -171,7 +171,7 @@ class SwAutoFormat
     SwTextFrame * EnsureFormatted(SwTextFrame const&) const;
 
     void BuildIndent();
-    void BuildText();
+    void BuildText(bool isReplaceStyles);
     void BuildTextIndent();
     void BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel );
     void BuildNegIndent( SwTwips nSpaces );
@@ -1438,7 +1438,7 @@ void SwAutoFormat::BuildTextIndent()
     AutoCorrect();
 }
 
-void SwAutoFormat::BuildText()
+void SwAutoFormat::BuildText(bool const isReplaceStyles)
 {
     SetRedlineText( STR_AUTOFMTREDL_SET_TMPL_TEXT );
     // read all succeeding paragraphs that belong to this text without 
indentation
@@ -1449,7 +1449,10 @@ void SwAutoFormat::BuildText()
         bBreak = !IsFastFullLine(*m_pCurTextFrame)
                 || IsBlanksInString(*m_pCurTextFrame)
                 || IsSentenceAtEnd(*m_pCurTextFrame);
-    SetColl( RES_POOLCOLL_TEXT, true );
+    if (isReplaceStyles)
+    {
+        SetColl( RES_POOLCOLL_TEXT, true );
+    }
     if( !bBreak )
     {
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
@@ -2564,7 +2567,10 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags const &
                 else
                 {
                     eStat = READ_NEXT_PARA;
-                    BuildText();
+                    if (!m_aFlags.bAFormatByInput)
+                    {
+                        BuildText(false);
+                    }
                 }
             }
             break;
@@ -2605,7 +2611,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags const &
                     else if( 0 > nSz )      // negative 1st line indentation
                         BuildNegIndent( aFInfo.GetLineStart() );
                     else                    // is _no_ indentation
-                        BuildText();
+                        BuildText(true);
                     eStat = READ_NEXT_PARA;
                 }
                 else if (!nLevel && pNextFrame &&
@@ -2633,12 +2639,12 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags const &
                     else if( nLevel )       // is indentation
                         BuildTextIndent();
                     else
-                        BuildText();
+                        BuildText(true);
                 }
                 else if( nLevel )
                     BuildTextIndent();
                 else
-                    BuildText();
+                    BuildText(true);
                 eStat = READ_NEXT_PARA;
             }
             break;
@@ -2674,7 +2680,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags const &
                         else if( pLRSpace->GetTextLeft() )   // is indentation
                             BuildTextIndent();
                         else
-                            BuildText();
+                            BuildText(true);
                     }
                 }
             }

Reply via email to