]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Kornel's gcc compile fix.
[lyx.git] / src / BufferParams.cpp
index 96aaf7af2826eb6a1b1811e80f3ad1fbb54b5a1f..f369c8d6d9cbdf03d67c3cf520ec2c45edc3a5ce 100644 (file)
@@ -363,6 +363,7 @@ BufferParams::BufferParams()
        columns = 1;
        listings_params = string();
        pagestyle = "default";
+       suppress_date = false;
        // white is equal to no background color
        backgroundcolor = lyx::rgbFromHexName("#ffffff");
        compressed = false;
@@ -539,6 +540,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\master") {
                lex.eatLine();
                master = lex.getString();
+       } else if (token == "\\suppress_date") {
+               lex >> suppress_date;
        } else if (token == "\\language") {
                readLanguage(lex);
        } else if (token == "\\inputencoding") {
@@ -641,7 +644,6 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                if (branch_ptr)
                                        branch_ptr->setFilenameSuffix(lex.getInteger());
                        }
-                       // not yet operational
                        if (tok == "\\color") {
                                lex.eatLine();
                                string color = lex.getString();
@@ -657,6 +659,7 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\index") {
                lex.eatLine();
                docstring index = lex.getDocString();
+               docstring shortcut;
                indiceslist().add(index);
                while (true) {
                        lex.next();
@@ -666,10 +669,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                        Index * index_ptr = indiceslist().find(index);
                        if (tok == "\\shortcut") {
                                lex.next();
+                               shortcut = lex.getDocString();
                                if (index_ptr)
-                                       index_ptr->setShortcut(lex.getDocString());
+                                       index_ptr->setShortcut(shortcut);
                        }
-                       // not yet operational
                        if (tok == "\\color") {
                                lex.eatLine();
                                string color = lex.getString();
@@ -679,7 +682,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                if (color == "none")
                                        color = lcolor.getX11Name(Color_background);
                                // FIXME UNICODE
-                               lcolor.setColor(to_utf8(index), color);
+                               if (!shortcut.empty())
+                                       lcolor.setColor(to_utf8(shortcut), color);
                        }
                }
        } else if (token == "\\author") {
@@ -863,6 +867,7 @@ void BufferParams::writeFile(ostream & os) const
           << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
           << "\n\\use_indices " << convert<string>(use_indices)
           << "\n\\paperorientation " << string_orientation[orientation]
+          << "\n\\suppress_date " << convert<string>(suppress_date)
           << '\n';
           if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
@@ -1492,6 +1497,12 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        "Textclass specific LaTeX commands.\n"
                        + tmppreamble + '\n';
 
+       // suppress date if selected
+       // use \@ifundefined because we cannot be sure that every document class
+       // has a \date command
+       if (suppress_date)
+               atlyxpreamble += "\\@ifundefined{date}{}{\\date{}}\n";
+
        /* the user-defined preamble */
        if (!containsOnly(preamble, " \n\t"))
                // FIXME UNICODE