sw/qa/extras/txtexport/data/bullets.odt |binary
 sw/qa/extras/txtexport/txtexport.cxx    |    7 ++++++-
 sw/source/filter/ascii/ascatr.cxx       |   17 ++++++++++++-----
 3 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit 4d151eaca11286f570c0e89dca35104e8a1607f0
Author:     Manish <mailmessgcn...@proton.me>
AuthorDate: Wed Apr 16 21:38:45 2025 +0530
Commit:     Sahil Gautam <sahil.gau...@collabora.com>
CommitDate: Fri Jul 11 12:42:42 2025 +0200

    tdf#118666 Fix indentation of headings when pasted as unformatted text
    
    Previously,the problem arose due to headings of various levels aligned at 
0.00"
    being affected by paragraph numbering rules. In this patch, some checks to 
skip
    indentation for styles such as headings of
    various levels that are aligned at 0.00" are introduced.
    
    Change-Id: I5513d78dc7f32a5caf56d93c4bedfc9bd8a8068d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184290
    Tested-by: Jenkins
    Reviewed-by: Sahil Gautam <sahil.gau...@collabora.com>

diff --git a/sw/qa/extras/txtexport/data/bullets.odt 
b/sw/qa/extras/txtexport/data/bullets.odt
index 43e0c2123ffc..8d1797d1d21a 100644
Binary files a/sw/qa/extras/txtexport/data/bullets.odt and 
b/sw/qa/extras/txtexport/data/bullets.odt differ
diff --git a/sw/qa/extras/txtexport/txtexport.cxx 
b/sw/qa/extras/txtexport/txtexport.cxx
index 8a958a4579f8..dfabd6c3b2db 100644
--- a/sw/qa/extras/txtexport/txtexport.cxx
+++ b/sw/qa/extras/txtexport/txtexport.cxx
@@ -70,7 +70,12 @@ CPPUNIT_TEST_FIXTURE(TxtExportTest, testBullets)
         "    2. Second" SAL_NEWLINE_STRING "        1. Second-first" 
SAL_NEWLINE_STRING
         "       Third, but deleted" SAL_NEWLINE_STRING "    3. Actual third" 
SAL_NEWLINE_STRING
         "" SAL_NEWLINE_STRING "Paragraph after numbering" SAL_NEWLINE_STRING
-        "Next paragraph" SAL_NEWLINE_STRING "Final paragraph" 
SAL_NEWLINE_STRING,
+        "Next paragraph" SAL_NEWLINE_STRING "Final paragraph" 
SAL_NEWLINE_STRING
+        "Some Heading Outline Tests" SAL_NEWLINE_STRING " 1  Heading Level 1" 
SAL_NEWLINE_STRING
+        " 1.1  Heading Level 2" SAL_NEWLINE_STRING " 1.1.1  Heading Level 3" 
SAL_NEWLINE_STRING
+        " 1.1.1.1  Heading Level 4" SAL_NEWLINE_STRING
+        "                     1.1.1.1.1  Heading Level 5" SAL_NEWLINE_STRING
+        " 1.1.1.1.1.1  Heading Level 6" SAL_NEWLINE_STRING,
         RTL_TEXTENCODING_UTF8);
 
     // To get the stuff back in the system's encoding
diff --git a/sw/source/filter/ascii/ascatr.cxx 
b/sw/source/filter/ascii/ascatr.cxx
index c4f4d1249070..e3ead0c11196 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -263,15 +263,22 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, 
SwContentNode& rNode )
     if (pNumRule && !nStrPos && rWrt.m_bExportParagraphNumbering && 
!bIsOneParagraph)
     {
         bool bIsOutlineNumRule = pNumRule == rNd.GetDoc().GetOutlineNumRule();
-
-        // indent each numbering level by 4 spaces
         OUString level;
         if (!bIsOutlineNumRule)
         {
-            for (int i = 0; i <= rNd.GetActualListLevel(); ++i)
-                level += "    ";
-        }
+            //ensures indentation is not applied to styles such as headings 
aligned at 0.00",in case of pasting as unformatted text.
+            //checks the left margin & the left margin for tab values is set 
to 0 & outline level > 0
+            bool bSkipIndentation = false;
+            if (rNd.GetLeftMarginWithNum() == 0 && rNd.GetAttrOutlineLevel() > 
0 && rNd.GetLeftMarginForTabCalculation() == 0)
+               bSkipIndentation = true;
 
+            if(!bSkipIndentation)
+            {
+                // indent each numbering level by 4 spaces
+                for (int i = 0; i <= rNd.GetActualListLevel(); ++i)
+                    level += "    ";
+            }
+        }
         // set up bullets or numbering
         OUString numString(rNd.GetNumString());
         if (numString.isEmpty() && !bIsOutlineNumRule)

Reply via email to