X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_plaintext.C;h=2f1a177439ea4d08d2dfa3a63b012804f33d7e69;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=5c7c32c390183dbca7c4cdaa9f54462a7d023b68;hpb=9d6cad3fe60696d795280a886623fdc9a89f9de6;p=lyx.git diff --git a/src/output_plaintext.C b/src/output_plaintext.C index 5c7c32c390..2f1a177439 100644 --- a/src/output_plaintext.C +++ b/src/output_plaintext.C @@ -24,14 +24,14 @@ #include "support/lstrings.h" -#include -using lyx::support::ascii_lowercase; -using lyx::support::compare_ascii_no_case; -using lyx::support::compare_no_case; -using lyx::support::contains; +namespace lyx { + +using support::ascii_lowercase; +using support::compare_ascii_no_case; +using support::compare_no_case; +using support::contains; -using lyx::pos_type; using std::endl; using std::ostream; using std::ofstream; @@ -39,18 +39,17 @@ using std::pair; using std::string; -void writeFileAscii(Buffer const & buf, - string const & fname, - OutputParams const & runparams) +void writeFileAscii(Buffer const & buf, string const & fname, + OutputParams const & runparams) { - ofstream ofs; - if (!::openFileWrite(ofs, fname)) + odocfstream ofs; + if (!openFileWrite(ofs, fname)) return; writeFileAscii(buf, ofs, runparams); } -void writeFileAscii(Buffer const & buf, ostream & os, +void writeFileAscii(Buffer const & buf, odocstream & os, OutputParams const & runparams) { bool ref_printed = false; @@ -67,12 +66,12 @@ void writeFileAscii(Buffer const & buf, ostream & os, namespace { -pair const addDepth(int depth, int ldepth) +pair const addDepth(int depth, int ldepth) { int d = depth * 2; if (ldepth > depth) d += (ldepth - depth) * 2; - return make_pair(d, string(d, ' ')); + return make_pair(d, docstring(d, ' ')); } } @@ -80,13 +79,13 @@ pair const addDepth(int depth, int ldepth) void asciiParagraph(Buffer const & buf, Paragraph const & par, - ostream & os, + odocstream & os, OutputParams const & runparams, bool & ref_printed) { int ltype = 0; - Paragraph::depth_type ltype_depth = 0; - Paragraph::depth_type depth = par.params().depth(); + depth_type ltype_depth = 0; + depth_type depth = par.params().depth(); // First write the layout string const & tmp = par.layout()->name(); @@ -135,7 +134,7 @@ void asciiParagraph(Buffer const & buf, if (runparams.linelen > 0) os << "\n\n"; - os << string(depth * 2, ' '); + os << docstring(depth * 2, ' '); currlinelen += depth * 2; //-- @@ -154,7 +153,7 @@ void asciiParagraph(Buffer const & buf, os << _("Abstract") << "\n\n"; currlinelen = 0; } else { - string const abst = _("Abstract: "); + docstring const abst = _("Abstract: "); os << abst; currlinelen += abst.length(); } @@ -166,7 +165,7 @@ void asciiParagraph(Buffer const & buf, os << _("References") << "\n\n"; currlinelen = 0; } else { - string const refs = _("References: "); + docstring const refs = _("References: "); os << refs; currlinelen += refs.length(); } @@ -175,7 +174,7 @@ void asciiParagraph(Buffer const & buf, break; default: { - string const label = par.params().labelString(); + docstring const label = par.params().labelString(); os << label << ' '; currlinelen += label.length() + 1; break; @@ -184,7 +183,7 @@ void asciiParagraph(Buffer const & buf, } if (!currlinelen) { - pair p = addDepth(depth, ltype_depth); + pair p = addDepth(depth, ltype_depth); os << p.second; currlinelen += p.first; } @@ -193,10 +192,10 @@ void asciiParagraph(Buffer const & buf, // intelligent hopefully! (only in the case where we have a // max runparams.linelength!) (Jug) - string word; + docstring word; for (pos_type i = 0; i < par.size(); ++i) { - char c = par.getUChar(buf.params(), i); + char_type c = par.getUChar(buf.params(), i); switch (c) { case Paragraph::META_INSET: { InsetBase const * inset = par.getInset(i); @@ -217,8 +216,8 @@ void asciiParagraph(Buffer const & buf, case ' ': if (runparams.linelen > 0 && currlinelen + word.length() > runparams.linelen - 10) { - os << "\n"; - pair p = addDepth(depth, ltype_depth); + os << '\n'; + pair p = addDepth(depth, ltype_depth); os << p.second; currlinelen = p.first; } @@ -237,8 +236,8 @@ void asciiParagraph(Buffer const & buf, if (runparams.linelen > 0 && currlinelen + word.length() > runparams.linelen) { - os << "\n"; - pair p = addDepth(depth, ltype_depth); + os << '\n'; + pair p = addDepth(depth, ltype_depth); os << p.second; currlinelen = p.first; } @@ -247,3 +246,6 @@ void asciiParagraph(Buffer const & buf, } os << word; } + + +} // namespace lyx