]> git.lyx.org Git - features.git/commitdiff
No need to use \fcolorbox with explicit black frame and no background
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 1 Oct 2023 08:12:52 +0000 (10:12 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 1 Oct 2023 08:12:52 +0000 (10:12 +0200)
White background, however, is always treated explicit (think non-white
page background)

src/insets/InsetBox.cpp
src/insets/InsetBox.h

index c15ae86c9869ec4b8fc00f087f796ee4c4f29907..8adf0f7fe02b87ee3cda385384bfc3519f3a1374 100644 (file)
@@ -430,9 +430,11 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                if (separation_string != defaultSep && thickness_string == defaultThick)
                        os << "{\\fboxsep " << from_ascii(separation_string);
                if (!params_.inner_box && !width_string.empty()) {
-                       if (params_.framecolor != "default" || params_.backgroundcolor != "none") {
-                               os << maybeBeginL << "\\fcolorbox{" << getFrameColor() << "}{" << getBackgroundColor() << "}{";
-                               os << "\\makebox";
+                       if (useFColorBox()) {
+                               os << maybeBeginL
+                                  << "\\fcolorbox{" << getFrameColor()
+                                  << "}{" << getBackgroundColor()
+                                  << "}{" << "\\makebox";
                                needEndL = !maybeBeginL.empty();
                        } else
                                os << "\\framebox";
@@ -449,8 +451,10 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                        if (params_.hor_pos != 'c')
                                os << "[" << params_.hor_pos << "]";
                } else {
-                       if (params_.framecolor != "default" || params_.backgroundcolor != "none") {
-                               os << maybeBeginL << "\\fcolorbox{" << getFrameColor() << "}{" << getBackgroundColor() << "}";
+                       if (useFColorBox()) {
+                               os << maybeBeginL
+                                  << "\\fcolorbox{" << getFrameColor()
+                                  << "}{" << getBackgroundColor() << "}";
                                needEndL = !maybeBeginL.empty();
                        } else {
                                if (!cprotect.empty() && contains(runparams.active_chars, '^')) {
@@ -616,8 +620,7 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                break;
        case Boxed:
                os << "}";
-               if (!params_.inner_box && !width_string.empty()
-                       && (params_.framecolor != "default" || params_.backgroundcolor != "none"))
+               if (!params_.inner_box && !width_string.empty() && useFColorBox())
                        os << "}";
                if (separation_string != defaultSep || thickness_string != defaultThick)
                        os << "}";
@@ -810,8 +813,8 @@ void InsetBox::validate(LaTeXFeatures & features) const
                break;
        case Boxed:
                features.require("calc");
-               if (params_.framecolor != "default" || params_.backgroundcolor != "none")
-                       // \fcolorbox, which is part of (x)color, is used
+               if (useFColorBox())
+                       // \fcolorbox is provided by [x]color
                        features.require("xcolor");
                break;
        case ovalbox:
@@ -892,6 +895,15 @@ string const InsetBox::getBackgroundColor() const
 }
 
 
+bool InsetBox::useFColorBox() const
+{
+       // we only need an \fcolorbox if the framecolor is something else
+       // than black in the output or if the backgroundcolor is not none
+       // (also needed with white, consider non-white page coloring)
+       return getFrameColor() != "black" || params_.backgroundcolor != "none";
+}
+
+
 /////////////////////////////////////////////////////////////////////////
 //
 // InsetBoxParams
index 97c2a27750d6ab90a391595e57e354b22bbb9525..f4a743667bbf9826c822df9443fb96efd41b637e 100644 (file)
@@ -167,6 +167,8 @@ private:
        std::string const getFrameColor(bool const gui = false) const;
        ///
        std::string const getBackgroundColor() const;
+       ///
+       bool useFColorBox() const;
 
        ///
        friend class InsetBoxParams;