From e8084b31096b6b60f501cf43fa9e84c81ea4e89a Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Tue, 20 Feb 2007 17:56:55 +0000 Subject: [PATCH] * src/output_plaintext.C: use InsetBase::PLAINTEXT_NEWLINE; refactor some common code; remove obsolete comments git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17276 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/output_plaintext.C | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/output_plaintext.C b/src/output_plaintext.C index 6ccb342265..375f107782 100644 --- a/src/output_plaintext.C +++ b/src/output_plaintext.C @@ -117,14 +117,8 @@ void writePlaintextParagraph(Buffer const & buf, ltype_depth = 0; } - /* maybe some vertical spaces */ - /* the labelwidthstring used in lists */ - /* some lines? */ - - /* some pagebreaks? */ - /* noindent ? */ /* what about the alignment */ @@ -192,12 +186,13 @@ void writePlaintextParagraph(Buffer const & buf, docstring word; for (pos_type i = 0; i < par.size(); ++i) { - if (par.isDeleted(i)) // deleted characters don't make much sense in plain text output + // deleted characters don't make much sense in plain text output + if (par.isDeleted(i)) continue; char_type c = par.getUChar(buf.params(), i); - switch (c) { - case Paragraph::META_INSET: { + + if (c == Paragraph::META_INSET || c == ' ') { if (runparams.linelen > 0 && currlinelen + word.length() > runparams.linelen) { os << '\n'; @@ -208,28 +203,23 @@ void writePlaintextParagraph(Buffer const & buf, os << word; currlinelen += word.length(); word.erase(); + } + switch (c) { + case Paragraph::META_INSET: { OutputParams rp = runparams; rp.depth = par.params().depth(); int len = par.getInset(i)->plaintext(buf, os, rp); - if (len >= runparams.linelen) - currlinelen = len - runparams.linelen; + if (len >= InsetBase::PLAINTEXT_NEWLINE) + currlinelen = len - InsetBase::PLAINTEXT_NEWLINE; else currlinelen += len; break; } case ' ': - if (runparams.linelen > 0 && - currlinelen + word.length() > runparams.linelen) { - os << '\n'; - pair p = addDepth(depth, ltype_depth); - os << p.second; - currlinelen = p.first; - } - os << word << ' '; - currlinelen += word.length() + 1; - word.erase(); + os << ' '; + currlinelen++; break; case '\0': -- 2.39.2