]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
A little more lv cleanup.
[lyx.git] / src / BufferParams.cpp
index 480ab941c2180757f6d0d2ede8812c19fb3a9971..5d6e56046ff45220afd5ab4d19a80145646c783c 100644 (file)
@@ -367,8 +367,12 @@ BufferParams::BufferParams()
        listings_params = string();
        pagestyle = "default";
        suppress_date = false;
-       // white is equal to no background color
+       // no color is the default (white)
        backgroundcolor = lyx::rgbFromHexName("#ffffff");
+       isbackgroundcolor = false;
+       // no color is the default (black)
+       fontcolor = lyx::rgbFromHexName("#000000");
+       isfontcolor = false;
        // light gray is the default font color for greyed-out notes
        notefontcolor = lyx::rgbFromHexName("#cccccc");
        compressed = lyxrc.save_compressed;
@@ -723,11 +727,17 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\backgroundcolor") {
                lex.eatLine();
                backgroundcolor = lyx::rgbFromHexName(lex.getString());
+               isbackgroundcolor = true;
+       } else if (token == "\\fontcolor") {
+               lex.eatLine();
+               fontcolor = lyx::rgbFromHexName(lex.getString());
+               isfontcolor = true;
        } else if (token == "\\notefontcolor") {
                lex.eatLine();
                string color = lex.getString();
                notefontcolor = lyx::rgbFromHexName(color);
                // set the font color within LyX
+               // FIXME: the color is correctly set but later overwritten by the default
                lcolor.setColor(Color_greyedouttext, color);
        } else if (token == "\\paperwidth") {
                lex >> paperwidth;
@@ -919,9 +929,11 @@ void BufferParams::writeFile(ostream & os) const
           << "\n\\paperorientation " << string_orientation[orientation]
           << "\n\\suppress_date " << convert<string>(suppress_date)
           << '\n';
-          if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
+       if (isbackgroundcolor == true)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
-          if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
+       if (isfontcolor == true)
+               os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
+       if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
                os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
 
        BranchList::const_iterator it = branchlist().begin();
@@ -1445,8 +1457,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                texrow.newline();
        }
 
-       // only output when the background color is not white
-       if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) {
+       // only output when the background color is not default
+       if (isbackgroundcolor == true) {
                // only require color here, the background color will be defined
                // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
                // package pdfpages 
@@ -1454,6 +1466,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                features.require("pagecolor");
        }
 
+       // only output when the font color is not default
+       if (isfontcolor == true) {
+               // only require color here, the font color will be defined
+               // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
+               // package pdfpages 
+               features.require("color");
+               features.require("fontcolor");
+       }
+
        // Only if class has a ToC hierarchy
        if (tclass.hasTocLevels()) {
                if (secnumdepth != tclass.secnumdepth()) {