X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_plaintext.cpp;h=9dae951f03915a0f9e2f14751e572d95014d9a1d;hb=bb277747d2fc128d65edb55662d075ce44100bc7;hp=476e62d368b0e0235bcded0767b8f8f5e46887db;hpb=cc1ce047984292b0509043f82165c506d15eb020;p=lyx.git diff --git a/src/output_plaintext.cpp b/src/output_plaintext.cpp index 476e62d368..9dae951f03 100644 --- a/src/output_plaintext.cpp +++ b/src/output_plaintext.cpp @@ -56,9 +56,11 @@ void writePlaintextFile(Buffer const & buf, odocstream & os, ParagraphList::const_iterator end = par.end(); ParagraphList::const_iterator it = beg; for (; it != end; ++it) { + bool const merged_par = (*it).parEndChange().deleted(); writePlaintextParagraph(buf, *it, os, runparams, ref_printed); - os << "\n"; - if (runparams.linelen > 0) + if (!merged_par) + os << "\n"; + if (runparams.linelen > 0 && !merged_par) os << "\n"; } } @@ -75,9 +77,9 @@ static pair addDepth(int depth, int ldepth) void writePlaintextParagraph(Buffer const & buf, Paragraph const & par, - odocstream & os, + odocstream & ods, OutputParams const & runparams, - bool & ref_printed) + bool & ref_printed, size_t max_length) { int ltype = 0; depth_type ltype_depth = 0; @@ -121,6 +123,7 @@ void writePlaintextParagraph(Buffer const & buf, string::size_type currlinelen = 0; + odocstringstream os; os << docstring(depth * 2, ' '); currlinelen += depth * 2; @@ -184,7 +187,10 @@ void writePlaintextParagraph(Buffer const & buf, if (par.isDeleted(i)) continue; - char_type c = par.getUChar(buf.params(), i); + if (os.str().size() > max_length) + break; + + char_type c = par.getUChar(buf.params(), runparams, i); if (par.isInset(i) || c == ' ') { if (runparams.linelen > 0 && @@ -202,7 +208,7 @@ void writePlaintextParagraph(Buffer const & buf, if (par.isInset(i)) { OutputParams rp = runparams; rp.depth = par.params().depth(); - int len = par.getInset(i)->plaintext(os, rp); + int len = par.getInset(i)->plaintext(os, rp, max_length); if (len >= Inset::PLAINTEXT_NEWLINE) currlinelen = len - Inset::PLAINTEXT_NEWLINE; else @@ -213,7 +219,7 @@ void writePlaintextParagraph(Buffer const & buf, switch (c) { case ' ': os << ' '; - currlinelen++; + ++currlinelen; break; case '\0': @@ -238,6 +244,7 @@ void writePlaintextParagraph(Buffer const & buf, } os << word; } + ods << os.str(); }