]> git.lyx.org Git - lyx.git/blobdiff - src/output_plaintext.cpp
* docstream: factorize out some code and introduce odocfstream::reset()
[lyx.git] / src / output_plaintext.cpp
index 6252056646124da202544a9835069a8a23dfdd47..eb11c576600a1bfa558f709c2cc7f6b79375f32e 100644 (file)
@@ -14,8 +14,9 @@
 
 #include "Buffer.h"
 #include "BufferParams.h"
-#include "debug.h"
-#include "gettext.h"
+#include "support/debug.h"
+#include "support/gettext.h"
+#include "Layout.h"
 #include "output.h"
 #include "OutputParams.h"
 #include "Paragraph.h"
@@ -41,7 +42,7 @@ using std::string;
 void writePlaintextFile(Buffer const & buf, FileName const & fname,
        OutputParams const & runparams)
 {
-       odocfstream ofs;
+       odocfstream ofs("UTF-8");
        if (!openFileWrite(ofs, fname))
                return;
        writePlaintextFile(buf, ofs, runparams);
@@ -89,7 +90,7 @@ void writePlaintextParagraph(Buffer const & buf,
        depth_type depth = par.params().depth();
 
        // First write the layout
-       string const & tmp = par.layout()->name();
+       string const tmp = to_utf8(par.layout()->name());
        if (compare_ascii_no_case(tmp, "itemize") == 0) {
                ltype = 1;
                ltype_depth = depth + 1;
@@ -131,7 +132,7 @@ void writePlaintextParagraph(Buffer const & buf,
 
        //--
        // we should probably change to the paragraph language in the
-       // gettext here (if possible) so that strings are output in
+       // support/gettext.here (if possible) so that strings are output in
        // the correct language! (20012712 Jug)
        //--
        switch (ltype) {
@@ -191,7 +192,7 @@ void writePlaintextParagraph(Buffer const & buf,
 
                char_type c = par.getUChar(buf.params(), i);
 
-               if (c == Paragraph::META_INSET || c == ' ') {
+               if (par.isInset(i) || c == ' ') {
                        if (runparams.linelen > 0 &&
                            currlinelen + word.length() > runparams.linelen) {
                                os << '\n';
@@ -204,8 +205,7 @@ void writePlaintextParagraph(Buffer const & buf,
                        word.erase();
                }
 
-               switch (c) {
-               case Paragraph::META_INSET: {
+               if (par.isInset(i)) {
                        OutputParams rp = runparams;
                        rp.depth = par.params().depth();
                        int len = par.getInset(i)->plaintext(buf, os, rp);
@@ -213,17 +213,17 @@ void writePlaintextParagraph(Buffer const & buf,
                                currlinelen = len - Inset::PLAINTEXT_NEWLINE;
                        else
                                currlinelen += len;
-                       break;
+                       continue;
                }
 
+               switch (c) {
                case ' ':
                        os << ' ';
                        currlinelen++;
                        break;
 
                case '\0':
-                       LYXERR(Debug::INFO) <<
-                               "writePlaintextFile: NULL char in structure." << endl;
+                       LYXERR(Debug::INFO, "writePlaintextFile: NULL char in structure.");
                        break;
 
                default: