[LyX/master] Amend 9a6b49d4f1e9

Juergen Spitzmueller <[email protected]>
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit 3c8ebd2213ca961f969d8745404acc400969f74f
Author: Juergen Spitzmueller <[email protected]>
Date:   Tue Mar 10 15:42:28 2026 +0100

    Amend 9a6b49d4f1e9
    
    load xcolor if needed
---
 src/BufferParams.cpp    |  4 ++--
 src/LaTeXFeatures.cpp   | 12 ++++++++++--
 src/LaTeXFeatures.h     |  3 ++-
 src/PDFOptions.cpp      |  2 +-
 src/insets/InsetBox.cpp |  4 ++--
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 9b73219b64..2935d96bcc 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2547,7 +2547,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 		// only require color here, the background color will be defined
 		// in LaTeXFeatures.cpp to avoid interferences with the LaTeX
 		// package pdfpages
-		features.requireColorPackage(backgroundcolor);
+		features.requireColorPackage(backgroundcolor, false, true);
 		features.require("pagecolor");
 	}
 
@@ -2556,7 +2556,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 		// only require color here, the font color will be defined
 		// in LaTeXFeatures.cpp to avoid interferences with the LaTeX
 		// package pdfpages
-		features.requireColorPackage(fontcolor);
+		features.requireColorPackage(fontcolor, false, true);
 		features.require("fontcolor");
 	}
 
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index a215a3a20e..43084df4b5 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -1321,7 +1321,8 @@ string const LaTeXFeatures::getColorValue(string const & col) const
 }
 
 
-bool LaTeXFeatures::requireColorPackage(string const & col, bool const islatexcol)
+bool LaTeXFeatures::requireColorPackage(string const & col, bool const islatexcol,
+					bool const xcolor)
 {
 	bool res = false;
 	if ((!islatexcol && theLaTeXColors().isLaTeXColor(col))
@@ -1330,7 +1331,10 @@ bool LaTeXFeatures::requireColorPackage(string const & col, bool const islatexco
 		LaTeXColor const lc = theLaTeXColors().getLaTeXColor(lyxcolor);
 		for (auto const & r : lc.req())
 			require(r);
-		require("color");
+		if (xcolor)
+			require("xcolor");
+		else
+			require("color");
 		if (!lc.model().empty()) {
 			require("xcolor");
 			require("xcolor:" + lc.model());
@@ -1341,6 +1345,10 @@ bool LaTeXFeatures::requireColorPackage(string const & col, bool const islatexco
 			if ((!islatexcol && lc.first == col) || (islatexcol && lc.second.latex() == col)){
 				for (auto const & r : lc.second.req())
 					require(r);
+				if (xcolor)
+					require("xcolor");
+				else
+					require("color");
 				if (!lc.second.model().empty()) {
 					require("xcolor");
 					require("xcolor:" + lc.second.model());
diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h
index b273a817ca..ff16d74d88 100644
--- a/src/LaTeXFeatures.h
+++ b/src/LaTeXFeatures.h
@@ -223,7 +223,8 @@ public:
 	///
 	bool haveOtherForceProvide() const;
 	///
-	bool requireColorPackage(std::string const & col, bool const islatexcol = false);
+	bool requireColorPackage(std::string const & col, bool const islatexcol = false,
+				 bool const xcolor = false);
 
 private:
 	///
diff --git a/src/PDFOptions.cpp b/src/PDFOptions.cpp
index 07c6b6f3c9..64394db4a7 100644
--- a/src/PDFOptions.cpp
+++ b/src/PDFOptions.cpp
@@ -315,7 +315,7 @@ void PDFOptions::validate(LaTeXFeatures & features) const
 		if (!contains(opt, "color="))
 			continue;
 		string const color = split(opt, '=');
-		features.requireColorPackage(color, true);
+		features.requireColorPackage(color, true, true);
 	}
 	
 }
diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp
index c94e89ce5a..e1a1b0aa05 100644
--- a/src/insets/InsetBox.cpp
+++ b/src/insets/InsetBox.cpp
@@ -796,7 +796,7 @@ void InsetBox::validate(LaTeXFeatures & features) const
 	switch (btype) {
 	case Frameless:
 		if (params_.backgroundcolor != "none") {
-			if (!features.requireColorPackage(params_.backgroundcolor))
+			if (!features.requireColorPackage(params_.backgroundcolor, false, true))
 				features.require("color");
 		}
 		break;
@@ -808,7 +808,7 @@ void InsetBox::validate(LaTeXFeatures & features) const
 		features.require("calc");
 		if (useFColorBox()) {
 			if (!features.requireColorPackage(params_.backgroundcolor)
-			     && !features.requireColorPackage(params_.framecolor))
+			     && !features.requireColorPackage(params_.framecolor, false, true))
 				features.require("color");
 		}
 		break;
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.