]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
GuiDocument.cpp: remove unneeded conversion
[lyx.git] / src / BufferParams.cpp
index f540cb543b5c0d2f322e15b5bc0ad3bfa3b0bf7f..9492f00f1503851cd50ecad0146b461b54d7b61b 100644 (file)
@@ -351,10 +351,13 @@ BufferParams::BufferParams()
        fontsTypewriterScale = 100;
        inputenc = "auto";
        graphicsDriver = "default";
+       defaultOutputFormat = "default";
        sides = OneSide;
        columns = 1;
        listings_params = string();
        pagestyle = "default";
+       // white is equal to no background color
+       backgroundcolor = lyx::rgbFromHexName("#ffffff");
        compressed = false;
        for (int iter = 0; iter < 4; ++iter) {
                user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
@@ -509,6 +512,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> inputenc;
        } else if (token == "\\graphics") {
                readGraphicsDriver(lex);
+       } else if (token == "\\default_output_format") {
+               lex >> defaultOutputFormat;
        } else if (token == "\\font_roman") {
                lex.eatLine();
                fontsRoman = lex.getString();
@@ -597,7 +602,6 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                        color = lcolor.getX11Name(Color_background);
                                // FIXME UNICODE
                                lcolor.setColor(to_utf8(branch), color);
-
                        }
                }
        } else if (token == "\\author") {
@@ -610,6 +614,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                string orient;
                lex >> orient;
                orientation = paperorientationtranslator().find(orient);
+       } else if (token == "\\backgroundcolor") {
+               lex.eatLine();
+               backgroundcolor = lyx::rgbFromHexName(lex.getString());
        } else if (token == "\\paperwidth") {
                lex >> paperwidth;
        } else if (token == "\\paperheight") {
@@ -758,6 +765,7 @@ void BufferParams::writeFile(ostream & os) const
                os << "\\font_cjk " << fontsCJK << '\n';
        }
        os << "\n\\graphics " << graphicsDriver << '\n';
+       os << "\\default_output_format " << defaultOutputFormat << '\n';
 
        if (!float_placement.empty()) {
                os << "\\float_placement " << float_placement << '\n';
@@ -774,6 +782,7 @@ void BufferParams::writeFile(ostream & os) const
           << "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
           << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
           << "\n\\paperorientation " << string_orientation[orientation]
+          << "\n\\backgroundcolor " << lyx::X11hexname(backgroundcolor)
           << '\n';
 
        BranchList::const_iterator it = branchlist().begin();
@@ -1260,6 +1269,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                texrow.newline();
        }
 
+       // only output when the background color is not white
+       if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) {
+               // only require color here, the background color will be defined
+               // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
+               // package pdfpages 
+               features.require("color");
+               features.require("pagecolor");
+       }
+
        // Only if class has a ToC hierarchy
        if (tclass.hasTocLevels()) {
                if (secnumdepth != tclass.secnumdepth()) {