#include "ParagraphList.h"
#include "ParagraphParameters.h"
+#include "insets/Inset.h"
+
#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
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";
}
}
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;
string::size_type currlinelen = 0;
+ odocstringstream os;
os << docstring(depth * 2, ' ');
currlinelen += depth * 2;
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 &&
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
switch (c) {
case ' ':
os << ' ';
- currlinelen++;
+ ++currlinelen;
break;
case '\0':
}
os << word;
}
+ ods << os.str();
}