sw/inc/shellio.hxx                   |    4 ---
 sw/qa/extras/txtimport/txtimport.cxx |   42 +++++++++++++++++++++++++++++++++++
 sw/source/filter/ascii/parasc.cxx    |   11 ---------
 3 files changed, 42 insertions(+), 15 deletions(-)

New commits:
commit 745898eb2af2686ffbdfdc0e44984db67b172a59
Author:     Radhey Parekh <radhey.par...@gmail.com>
AuthorDate: Mon Jan 2 06:25:33 2023 +0100
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Mon Jan 2 07:36:05 2023 +0000

    tdf#70423 Remove txtimport break in 10k chars line
    
    This patch fixes the tdf#70423 which is an unexpected line break for
    ~10k characters. The fix consists of removing part of the code that
    creates a new paragraph when reaching ~10k characters. The limit was
    not exactly 10k characters, because the code tried to break at space
    character when reaching around 10k-100 characters.
    
    A test is also created, which can be checked by invoking:
    
        make CPPUNIT_TEST_NAME="testTdf70423" -sr CppunitTest_sw_txtimport
    
    The test checks that there should be exactly 1 paragraph with 30k
    characters inside it.
    
    Change-Id: Ic37c2b6eb89b52b533e34dd117b9635b9608bab2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121548
    Tested-by: Hossein <hoss...@libreoffice.org>
    Reviewed-by: Hossein <hoss...@libreoffice.org>

diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index 0fe3985597ef..e666442d19a9 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -51,10 +51,6 @@ struct Writer_Impl;
 namespace sw::mark { class IMark; }
 namespace com::sun::star::embed { class XStorage; }
 
-// Defines the count of chars at which a paragraph read via ASCII/W4W-Reader
-// is forced to wrap. It has to be always greater than 200!!!
-#define MAX_ASCII_PARA 10000
-
 class SW_DLLPUBLIC SwAsciiOptions
 {
     OUString m_sFont;
diff --git a/sw/qa/extras/txtimport/txtimport.cxx 
b/sw/qa/extras/txtimport/txtimport.cxx
index 8be577b4b328..10a4e54d429c 100644
--- a/sw/qa/extras/txtimport/txtimport.cxx
+++ b/sw/qa/extras/txtimport/txtimport.cxx
@@ -15,6 +15,7 @@
 #include <unotxdoc.hxx>
 #include <docsh.hxx>
 #include <wrtsh.hxx>
+#include <rtl/ustrbuf.hxx>
 
 class TxtImportTest : public SwModelTestBase
 {
@@ -190,6 +191,47 @@ CPPUNIT_TEST_FIXTURE(TxtImportTest, testTdf115088)
     CPPUNIT_ASSERT_EQUAL(OUString("1\n"), aActual.replaceAll("\r", "\n"));
 }
 
+CPPUNIT_TEST_FIXTURE(TxtImportTest, testTdf70423)
+{
+    createSwDoc();
+    SwDoc* pDoc = getSwDoc();
+    CPPUNIT_ASSERT(pDoc);
+
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    constexpr sal_Int32 size = 30000; // It should be multiple of 10
+    constexpr sal_Int32 parts = size / 10;
+
+    rtl::OUStringBuffer s(size);
+
+    for (size_t i = 0; i < parts; i++)
+    {
+        s.append("0123456789");
+    }
+
+    OUString aResStr = s.makeStringAndClear();
+    pWrtShell->Insert(aResStr);
+
+    save("Text", "maTempFile"); //Saving the resulting file
+    reload(mpFilter, "Text"); //Reloading the file again
+
+    // Without the fix, this test would have failed with:
+    // - Expected: 1
+    // - Actual: 3
+    CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
+
+    uno::Reference<text::XTextRange> xPara(getParagraph(1));
+    OUString aPara = xPara->getString();
+
+    // Without the fix, this test would have failed with:
+    // - Expected: 30000
+    // - Actual: 10000
+    CPPUNIT_ASSERT_EQUAL(size, aPara.getLength());
+
+    //Matching the paragraph text and created string
+    CPPUNIT_ASSERT_EQUAL(aResStr, aPara);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ascii/parasc.cxx 
b/sw/source/filter/ascii/parasc.cxx
index b29251bcbd8b..eab7a59e898b 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -474,17 +474,6 @@ ErrCode SwASCIIParser::ReadChars()
 
         if( bIns )
         {
-            if( ( nLineLen >= MAX_ASCII_PARA - 100 ) &&
-                ( ( *pStt == ' ' ) || ( nLineLen >= MAX_ASCII_PARA - 1 ) ) )
-            {
-                sal_Unicode c = *pStt;
-                *pStt = 0;
-                InsertText( OUString( pLastStt ));
-                
m_rDoc.getIDocumentContentOperations().SplitNode(*m_oPam->GetPoint(), false);
-                pLastStt = pStt;
-                nLineLen = 0;
-                *pStt = c;
-            }
             ++pStt;
             ++nLineLen;
         }

Reply via email to