]> git.lyx.org Git - lyx.git/blobdiff - src/output_plaintext.cpp
#5502 add binding for full screen toggle on mac
[lyx.git] / src / output_plaintext.cpp
index 476e62d368b0e0235bcded0767b8f8f5e46887db..15e700eb8f1cf564d92b0eb273483d2942234a3a 100644 (file)
@@ -75,9 +75,9 @@ static pair<int, docstring> 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 +121,7 @@ void writePlaintextParagraph(Buffer const & buf,
 
        string::size_type currlinelen = 0;
 
+       odocstringstream os;
        os << docstring(depth * 2, ' ');
        currlinelen += depth * 2;
 
@@ -184,6 +185,9 @@ void writePlaintextParagraph(Buffer const & buf,
                if (par.isDeleted(i))
                        continue;
 
+               if (os.str().size() > max_length)
+                       break;
+
                char_type c = par.getUChar(buf.params(), i);
 
                if (par.isInset(i) || c == ' ') {
@@ -202,7 +206,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 +217,7 @@ void writePlaintextParagraph(Buffer const & buf,
                switch (c) {
                case ' ':
                        os << ' ';
-                       currlinelen++;
+                       ++currlinelen;
                        break;
 
                case '\0':
@@ -238,6 +242,7 @@ void writePlaintextParagraph(Buffer const & buf,
                }
                os << word;
        }
+       ods << os.str();
 }