]> git.lyx.org Git - lyx.git/blobdiff - src/bufferparams.C
* Painter.h:
[lyx.git] / src / bufferparams.C
index ab542c0db2ba6dc66bd4abd3c07084cf7b062393..1af925829e9eb59f279a7c58dab23f7b347b9842 100644 (file)
 
 #include <sstream>
 
-namespace support = lyx::support;
 
-using lyx::docstring;
-using lyx::odocstream;
-using lyx::support::bformat;
-using lyx::support::rtrim;
-using lyx::support::tokenPos;
+namespace lyx {
+
+using support::bformat;
+using support::rtrim;
+using support::tokenPos;
 
 using std::endl;
 using std::string;
@@ -62,7 +61,6 @@ using std::ostringstream;
 using std::pair;
 
 namespace Alert = lyx::frontend::Alert;
-namespace biblio = lyx::biblio;
 
 
 // Local translators
@@ -433,7 +431,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                if (!getLyXTextClass().isTeXClassAvailable()) {
                        docstring const msg =
                                bformat(_("The document uses a missing "
-                                                      "TeX class \"%1$s\".\n"), lyx::from_utf8(classname));
+                                                      "TeX class \"%1$s\".\n"), from_utf8(classname));
                        Alert::warning(_("Document class not available"),
                                       msg + _("LyX will not be able to produce output."));
                }
@@ -729,10 +727,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        }
 
        // custom, A3, B3 and B4 paper sizes need geometry
-       bool nonstandard_papersize = (papersize == PAPER_B3) ||
-                                    (papersize == PAPER_B4) ||
-                                    (papersize == PAPER_A3) ||
-                                    (papersize == PAPER_CUSTOM);
+       bool nonstandard_papersize = papersize == PAPER_B3 
+               || papersize == PAPER_B4
+               || papersize == PAPER_A3
+               || papersize == PAPER_CUSTOM;
 
        if (!use_geometry) {
                switch (papersize) {
@@ -811,10 +809,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        if (!strOptions.empty()) {
                strOptions = rtrim(strOptions, ",");
                // FIXME UNICODE
-               os << '[' << lyx::from_utf8(strOptions) << ']';
+               os << '[' << from_utf8(strOptions) << ']';
        }
 
-       os << '{' << lyx::from_ascii(tclass.latexname()) << "}\n";
+       os << '{' << from_ascii(tclass.latexname()) << "}\n";
        texrow.newline();
        // end of \documentclass defs
 
@@ -824,45 +822,39 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                          fontsTypewriter, fontsSC, fontsOSF,
                          fontsSansScale, fontsTypewriterScale);
        if (!fonts.empty()) {
-               os << lyx::from_ascii(fonts);
+               os << from_ascii(fonts);
                texrow.newline();
        }
        if (fontsDefaultFamily != "default")
                os << "\\renewcommand{\\familydefault}{\\"
-                  << lyx::from_ascii(fontsDefaultFamily) << "}\n";
+                  << from_ascii(fontsDefaultFamily) << "}\n";
        // this one is not per buffer
        if (lyxrc.fontenc != "default") {
-               os << "\\usepackage[" << lyx::from_ascii(lyxrc.fontenc)
+               os << "\\usepackage[" << from_ascii(lyxrc.fontenc)
                   << "]{fontenc}\n";
                texrow.newline();
        }
 
-       // TODO: Some people want to support more encodings than UTF-8. They can have a field day around here
-       if (true) {
-               os << "\\usepackage[utf8]{inputenc}\n";
+       if (inputenc == "auto") {
+               string const doc_encoding =
+                       language->encoding()->latexName();
+
+               // Create a list with all the input encodings used
+               // in the document
+               std::set<string> encodings =
+                       features.getEncodingSet(doc_encoding);
+
+               os << "\\usepackage[";
+               std::set<string>::const_iterator it = encodings.begin();
+               std::set<string>::const_iterator const end = encodings.end();
+               for (; it != end; ++it)
+                       os << from_ascii(*it) << ',';
+               os << from_ascii(doc_encoding) << "]{inputenc}\n";
+               texrow.newline();
+       } else if (inputenc != "default") {
+               os << "\\usepackage[" << from_ascii(inputenc)
+                  << "]{inputenc}\n";
                texrow.newline();
-       } else {
-               if (inputenc == "auto") {
-                       string const doc_encoding =
-                               language->encoding()->latexName();
-
-                       // Create a list with all the input encodings used
-                       // in the document
-                       std::set<string> encodings =
-                               features.getEncodingSet(doc_encoding);
-
-                       os << "\\usepackage[";
-                       std::set<string>::const_iterator it = encodings.begin();
-                       std::set<string>::const_iterator const end = encodings.end();
-                       for (; it != end; ++it)
-                               os << lyx::from_ascii(*it) << ',';
-                       os << lyx::from_ascii(doc_encoding) << "]{inputenc}\n";
-                       texrow.newline();
-               } else if (inputenc != "default") {
-                       os << "\\usepackage[" << lyx::from_ascii(inputenc)
-                          << "]{inputenc}\n";
-                       texrow.newline();
-               }
        }
 
        if (use_geometry || nonstandard_papersize) {
@@ -875,10 +867,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                case PAPER_CUSTOM:
                        if (!paperwidth.empty())
                                os << ",paperwidth="
-                                  << lyx::from_ascii(paperwidth);
+                                  << from_ascii(paperwidth);
                        if (!paperheight.empty())
                                os << ",paperheight="
-                                  << lyx::from_ascii(paperheight);
+                                  << from_ascii(paperheight);
                        break;
                case PAPER_USLETTER:
                        os << ",letterpaper";
@@ -939,19 +931,19 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        }
                }
                if (!topmargin.empty())
-                       os << ",tmargin=" << lyx::from_ascii(topmargin);
+                       os << ",tmargin=" << from_ascii(topmargin);
                if (!bottommargin.empty())
-                       os << ",bmargin=" << lyx::from_ascii(bottommargin);
+                       os << ",bmargin=" << from_ascii(bottommargin);
                if (!leftmargin.empty())
-                       os << ",lmargin=" << lyx::from_ascii(leftmargin);
+                       os << ",lmargin=" << from_ascii(leftmargin);
                if (!rightmargin.empty())
-                       os << ",rmargin=" << lyx::from_ascii(rightmargin);
+                       os << ",rmargin=" << from_ascii(rightmargin);
                if (!headheight.empty())
-                       os << ",headheight=" << lyx::from_ascii(headheight);
+                       os << ",headheight=" << from_ascii(headheight);
                if (!headsep.empty())
-                       os << ",headsep=" << lyx::from_ascii(headsep);
+                       os << ",headsep=" << from_ascii(headsep);
                if (!footskip.empty())
-                       os << ",footskip=" << lyx::from_ascii(footskip);
+                       os << ",footskip=" << from_ascii(footskip);
                os << "}\n";
                texrow.newline();
        }
@@ -962,7 +954,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        os << "\\usepackage{fancyhdr}\n";
                        texrow.newline();
                }
-               os << "\\pagestyle{" << lyx::from_ascii(pagestyle) << "}\n";
+               os << "\\pagestyle{" << from_ascii(pagestyle) << "}\n";
                texrow.newline();
        }
 
@@ -995,7 +987,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        break;
                case VSpace::LENGTH:
                        os << "\\setlength\\parskip{"
-                          << lyx::from_ascii(getDefSkip().length().asLatexString())
+                          << from_utf8(getDefSkip().length().asLatexString())
                           << "}\n";
                        break;
                default: // should never happen // Then delete it.
@@ -1010,9 +1002,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
 
        // If we use jurabib, we have to call babel here.
        if (use_babel && features.isRequired("jurabib")) {
-               os << lyx::from_ascii(babelCall(language_options.str()))
+               os << from_ascii(babelCall(language_options.str()))
                   << '\n'
-                  << lyx::from_ascii(features.getBabelOptions());
+                  << from_ascii(features.getBabelOptions());
                texrow.newline();
        }
 
@@ -1111,7 +1103,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        }
 
        // FIXME UNICODE
-       os << lyx::from_utf8(lyxpreamble);
+       os << from_utf8(lyxpreamble);
        return use_babel;
 }
 
@@ -1449,3 +1441,6 @@ string const BufferParams::loadFonts(LaTeXFeatures & features, string const & rm
 
        return os.str();
 }
+
+
+} // namespace lyx