X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_plaintext.cpp;h=d58c44a7964f42fdc5e75e5cb75451c1e0aa609c;hb=57a8ea32c0a2443c188a522b516100bb74ec4a8d;hp=76987b7b4b11c2424ea6b9894cf055a6d0ac4c04;hpb=32871c1284f15265f652ff01c438e539a7c8181f;p=lyx.git diff --git a/src/output_plaintext.cpp b/src/output_plaintext.cpp index 76987b7b4b..d58c44a796 100644 --- a/src/output_plaintext.cpp +++ b/src/output_plaintext.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. */ @@ -14,36 +14,34 @@ #include "Buffer.h" #include "BufferParams.h" -#include "debug.h" -#include "gettext.h" +#include "Layout.h" #include "output.h" #include "OutputParams.h" #include "Paragraph.h" #include "ParagraphList.h" #include "ParagraphParameters.h" +#include "support/debug.h" +#include "support/gettext.h" #include "support/lstrings.h" +using namespace std; +using namespace lyx::support; namespace lyx { -using support::ascii_lowercase; -using support::compare_ascii_no_case; -using support::contains; -using support::FileName; - -using std::endl; -using std::ostream; -using std::pair; -using std::string; - void writePlaintextFile(Buffer const & buf, FileName const & fname, OutputParams const & runparams) { - odocfstream ofs; + ofdocstream ofs; if (!openFileWrite(ofs, fname)) return; + + // make sure we are ready to export + buf.updateBuffer(); + buf.updateMacroInstances(OutputUpdate); + writePlaintextFile(buf, ofs, runparams); } @@ -52,7 +50,7 @@ void writePlaintextFile(Buffer const & buf, odocstream & os, OutputParams const & runparams) { bool ref_printed = false; - ParagraphList const par = buf.paragraphs(); + ParagraphList const & par = buf.paragraphs(); ParagraphList::const_iterator beg = par.begin(); ParagraphList::const_iterator end = par.end(); ParagraphList::const_iterator it = beg; @@ -65,9 +63,7 @@ void writePlaintextFile(Buffer const & buf, odocstream & os, } -namespace { - -pair const addDepth(int depth, int ldepth) +static pair addDepth(int depth, int ldepth) { int d = depth * 2; if (ldepth > depth) @@ -75,9 +71,6 @@ pair const addDepth(int depth, int ldepth) return make_pair(d, docstring(d, ' ')); } -} - - void writePlaintextParagraph(Buffer const & buf, Paragraph const & par, odocstream & os, @@ -89,7 +82,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 +124,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) { @@ -142,10 +135,10 @@ void writePlaintextParagraph(Buffer const & buf, case 6: // Abstract if (runparams.linelen > 0) { - os << _("Abstract") << "\n\n"; + os << buf.B_("Abstract") << "\n\n"; currlinelen = 0; } else { - docstring const abst = _("Abstract: "); + docstring const abst = buf.B_("Abstract: "); os << abst; currlinelen += abst.length(); } @@ -154,10 +147,10 @@ void writePlaintextParagraph(Buffer const & buf, case 7: // Bibliography if (!ref_printed) { if (runparams.linelen > 0) { - os << _("References") << "\n\n"; + os << buf.B_("References") << "\n\n"; currlinelen = 0; } else { - docstring const refs = _("References: "); + docstring const refs = buf.B_("References: "); os << refs; currlinelen += refs.length(); } @@ -191,7 +184,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,26 +197,25 @@ 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); + int len = par.getInset(i)->plaintext(os, rp); if (len >= Inset::PLAINTEXT_NEWLINE) 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: NUL char in structure."); break; default: