mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Prevent more local colors from leaking (#6626)
This commit is contained in:
parent
b1e9206cab
commit
6775d7c3a2
@ -988,7 +988,7 @@ int Buffer::readHeader(Lexer & lex)
|
||||
<< token << '\'');
|
||||
|
||||
string const result =
|
||||
params().readToken(lex, token, d->filename.onlyPath());
|
||||
params().readToken(lex, token, d->filename);
|
||||
if (!result.empty()) {
|
||||
if (token == "\\textclass") {
|
||||
d->layout_position = result;
|
||||
|
@ -704,9 +704,10 @@ BufferParams::MathNumber BufferParams::getMathNumber() const
|
||||
|
||||
|
||||
string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
FileName const & filepath)
|
||||
FileName const & filename)
|
||||
{
|
||||
string result;
|
||||
FileName const & filepath = filename.onlyPath();
|
||||
|
||||
if (token == "\\textclass") {
|
||||
lex.next();
|
||||
@ -1028,7 +1029,7 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
color = lcolor.getX11HexName(Color_background);
|
||||
// FIXME UNICODE
|
||||
if (!shortcut.empty())
|
||||
lcolor.setColor(to_utf8(shortcut), color);
|
||||
lcolor.setColor(to_utf8(shortcut)+ "@" + filename.absFileName(), color);
|
||||
}
|
||||
}
|
||||
} else if (token == "\\author") {
|
||||
@ -1055,12 +1056,14 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
notefontcolor = lyx::rgbFromHexName(color);
|
||||
lcolor.setColor("notefontcolor", color);
|
||||
lcolor.setLaTeXName("notefontcolor", "note_fontcolor");
|
||||
// set a local name for the painter
|
||||
lcolor.setColor("notefontcolor@" + filename.absFileName(), color);
|
||||
isnotefontcolor = true;
|
||||
} else if (token == "\\boxbgcolor") {
|
||||
lex.eatLine();
|
||||
string color = lex.getString();
|
||||
boxbgcolor = lyx::rgbFromHexName(color);
|
||||
lcolor.setColor("boxbgcolor", color);
|
||||
lcolor.setColor("boxbgcolor@" + filename.absFileName(), color);
|
||||
isboxbgcolor = true;
|
||||
} else if (token == "\\paperwidth") {
|
||||
lex >> paperwidth;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "Citation.h"
|
||||
#include "ColorCode.h"
|
||||
#include "ColorSet.h"
|
||||
#include "DocumentClassPtr.h"
|
||||
#include "LayoutModuleList.h"
|
||||
#include "paper.h"
|
||||
@ -78,7 +79,7 @@ public:
|
||||
/// read a header token, if unrecognised, return it or an unknown class name
|
||||
std::string readToken(Lexer & lex,
|
||||
std::string const & token, ///< token to read.
|
||||
support::FileName const & filepath);
|
||||
support::FileName const & filename);
|
||||
|
||||
///
|
||||
void writeFile(std::ostream &, Buffer const *) const;
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Translator.h"
|
||||
@ -220,10 +221,10 @@ ColorCode InsetBox::backgroundColor(PainterInfo const &) const
|
||||
return getLayout().bgcolor();
|
||||
|
||||
if (params_.type == "Shaded") {
|
||||
if (buffer().params().isboxbgcolor)
|
||||
if (!buffer().params().isboxbgcolor)
|
||||
return getLayout().bgcolor();
|
||||
|
||||
ColorCode c = lcolor.getFromLyXName("boxbgcolor");
|
||||
ColorCode c = lcolor.getFromLyXName("boxbgcolor@" + buffer().fileName().absFileName());
|
||||
if (c == Color_none)
|
||||
return getLayout().bgcolor();
|
||||
return c;
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -456,7 +457,8 @@ ColorCode InsetIndex::labelColor() const
|
||||
if (params_.index.empty() || params_.index == from_ascii("idx"))
|
||||
return InsetCollapsible::labelColor();
|
||||
// FIXME UNICODE
|
||||
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
|
||||
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index)
|
||||
+ "@" + buffer().fileName().absFileName());
|
||||
if (c == Color_none)
|
||||
c = InsetCollapsible::labelColor();
|
||||
return c;
|
||||
|
@ -332,6 +332,10 @@ FontInfo InsetNote::getFont() const
|
||||
ColorCode c = lcolor.getFromLyXName("notefontcolor");
|
||||
if (c != Color_none)
|
||||
font.setColor(c);
|
||||
// This is the local color (not overridden by other documents)
|
||||
ColorCode lc = lcolor.getFromLyXName("notefontcolor@" + buffer().fileName().absFileName());
|
||||
if (lc != Color_none)
|
||||
font.setPaintColor(lc);
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user