]> git.lyx.org Git - lyx.git/blobdiff - src/bufferparams.C
last Friday's text*.C -> text_func shuffle
[lyx.git] / src / bufferparams.C
index 8354e7d23fbe65d299aaaf9819d8200d8fbc2701..bf70b6a66d2ca086c405f39d027912e88d1b2813 100644 (file)
 #include "lyxlex.h"
 #include "Lsstream.h"
 #include "author.h"
+#include "gettext.h"
 
 #include "support/lyxalgo.h" // for lyx::count
 #include "support/lyxlib.h"
 #include "support/lstrings.h"
 #include "support/types.h"
 
+#include "frontends/Alert.h"
+
 #include <cstdlib>
 #include <algorithm>
 
+using namespace lyx::support;
+
 using std::ostream;
 using std::endl;
 using std::pair;
 
-#ifdef WITH_WARNINGS
-#warning Do we need this horrible thing? (JMarc)
-#endif
-bool use_babel;
 
 BufferParams::BufferParams()
        // Initialize textclass to point to article. if `first' is
@@ -92,6 +93,12 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                        textclass = 0;
                        return classname;
                }
+               if (!getLyXTextClass().isTeXClassAvailable()) {
+                       string msg = bformat(_("The document uses a missing "
+                               "TeX class \"%1$s\".\n"), classname);
+                       Alert::warning(_("Document class not available"),
+                                      msg + _("LyX will not be able to produce output."));
+               }
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
        } else if (token == "\\options") {
@@ -160,14 +167,14 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                if (tmpret == -1)
                        ++tmpret;
                else
-                       papersize2 = tmpret;
+                       papersize2 = VMARGIN_PAPER_TYPE(tmpret);
        } else if (token == "\\paperpackage") {
                int tmpret = lex.findToken(string_paperpackages);
                if (tmpret == -1) {
                        ++tmpret;
                        paperpackage = BufferParams::PACKAGE_NONE;
                } else
-                       paperpackage = tmpret;
+                       paperpackage = PAPER_PACKAGES(tmpret);
        } else if (token == "\\use_geometry") {
                lex.nextToken();
                use_geometry = lex.getInteger();
@@ -186,11 +193,10 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                tracking_changes = lex.getInteger();
        } else if (token == "\\author") {
                lex.nextToken();
-               istringstream ss(lex.getString());
+               istringstream ss(STRCONV(lex.getString()));
                Author a;
                ss >> a;
-               int aid(authorlist.record(a));
-               author_ids.push_back(aid);
+               author_map.push_back(authorlist.record(a));
        } else if (token == "\\paperorientation") {
                int tmpret = lex.findToken(string_orientation);
                if (tmpret == -1)
@@ -450,7 +456,7 @@ void BufferParams::writeFile(ostream & os) const
 }
 
 
-void BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
+bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
                              TexRow & texrow) const
 {
        os << "\\documentclass";
@@ -469,6 +475,9 @@ void BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
        if (!use_geometry &&
            (paperpackage == PACKAGE_NONE)) {
                switch (papersize) {
+               case PAPER_A3PAPER:
+                       clsoptions << "a3paper,";
+                       break;
                case PAPER_A4PAPER:
                        clsoptions << "a4paper,";
                        break;
@@ -487,6 +496,8 @@ void BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
                case PAPER_LEGALPAPER:
                        clsoptions << "legalpaper,";
                        break;
+               case PAPER_DEFAULT:
+                       break;
                }
        }
 
@@ -515,17 +526,14 @@ void BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
                clsoptions << "landscape,";
 
        // language should be a parameter to \documentclass
-       use_babel = false;
-       ostringstream language_options;
        if (language->babel() == "hebrew"
            && default_language->babel() != "hebrew")
                // This seems necessary
                features.useLanguage(default_language);
 
-       if (lyxrc.language_use_babel ||
-           language->lang() != lyxrc.default_language ||
-           features.hasLanguages()) {
-               use_babel = true;
+       ostringstream language_options;
+       bool const use_babel = features.useBabel();
+       if (use_babel) {
                language_options << features.getLanguages();
                language_options << language->babel();
                if (lyxrc.language_global_options)
@@ -588,6 +596,8 @@ void BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
        // At the very beginning the text parameters.
        if (paperpackage != PACKAGE_NONE) {
                switch (paperpackage) {
+               case PACKAGE_NONE:
+                       break;
                case PACKAGE_A4:
                        os << "\\usepackage{a4}\n";
                        texrow.newline();
@@ -837,6 +847,7 @@ void BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
        }
 
        os << lyxpreamble;
+       return use_babel;
 }
 
 void BufferParams::setPaperStuff()