sw/source/core/edit/autofmt.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 8dbe20acb5ec2d01c88f040bb42cc49cc9167b84
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Thu Aug 21 18:23:56 2025 -0400
Commit:     Justin Luth <justin.l...@collabora.com>
CommitDate: Fri Aug 22 15:32:36 2025 +0200

    tdf#67797 autofmt: don't delete leading blanks without bSetNumRule
    
    If autoFormat is not going to turn the text into a list,
      [m_aFlags.bSetNumRule for [T]]
    or a style
      [! m_aFlags.bAFormatAsInput which is [M]]
    then don't automatically delete the leading/following blanks.
    
    This specifically became very inconsistent with
        A. List item 1
        B. List item 2
        C. List item 3   #DeleteLeadingTrailingBlanks called
    since A and B are not recognized as numbering,
    but C is considered part of a Roman numbering list.
    
    But even
        1. List item #DeleteLeadingTrailingBlanks called
    should not actually strip out the leading blanks
    unless it is actually going to be changed into a list
    (or if the style is going to be changed).
    
    Note that "Delete spaces and tabs at beginning and end of paragraph"
      [m_aFlags.bAFormatByInpDelSpacesAtSttEnd for [T]]
    is only supposed to apply if "Apply Styles" is also enabled.
      [m_aFlags.bReplaceStyles for [T]]
    
    Change-Id: Ie381c65a8f664393dd3428b5615502c17fc9f228
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190043
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 8b5dd3c05224..c5689473ee29 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1504,7 +1504,9 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 
nDigitLevel )
     bool bIsShortBullet = sStrWithTrailingBlanks == "* " || 
sStrWithTrailingBlanks == "- ";
     sal_uInt16 nMinLen = bIsShortBullet ? 1 : 2;
 
-    DeleteLeadingTrailingBlanks();
+    // only delete blanks if something else (numbering or style) is going to 
be changed
+    if (m_aFlags.bSetNumRule || !m_aFlags.bAFormatByInput || 
m_aFlags.bReplaceStyles)
+        DeleteLeadingTrailingBlanks();
 
     bool bChgBullet = false, bChgEnum = false;
     TextFrameIndex nAutoCorrPos(0);

Reply via email to