X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetGraphicsParams.cpp;h=9f6ffbb901ecbca5e387869c83d887a247582622;hb=997f0621c5346bb623cf86713c4fe1be0c941104;hp=15d6cad7a4a1324173a414e0ce4a71df4e9d8c0b;hpb=dc6d201f8fca2110e81617020f00b31692bde004;p=lyx.git diff --git a/src/insets/InsetGraphicsParams.cpp b/src/insets/InsetGraphicsParams.cpp index 15d6cad7a4..9f6ffbb901 100644 --- a/src/insets/InsetGraphicsParams.cpp +++ b/src/insets/InsetGraphicsParams.cpp @@ -50,12 +50,13 @@ InsetGraphicsParams::InsetGraphicsParams(InsetGraphicsParams const & igp) } -void InsetGraphicsParams::operator=(InsetGraphicsParams const & params) +InsetGraphicsParams & InsetGraphicsParams::operator=(InsetGraphicsParams const & params) { // Are we assigning the object into itself? if (this == ¶ms) - return; + return *this; copy(params); + return *this; } @@ -63,7 +64,7 @@ void InsetGraphicsParams::init() { filename.erase(); lyxscale = 100; // lyx scaling in percentage - display = true; // may be overriden by display mode in preferences + display = true; // may be overridden by display mode in preferences scale = string("100"); // output scaling in percentage width = Length(); height = Length(); @@ -73,6 +74,7 @@ void InsetGraphicsParams::init() bbox = graphics::BoundingBox(); // bounding box clip = false; // clip image + darkModeSensitive = false; // dark mode dependency rotateAngle = "0"; // angle of rotation in degrees rotateOrigin.erase(); // Origin of rotation @@ -81,25 +83,26 @@ void InsetGraphicsParams::init() } -void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) +void InsetGraphicsParams::copy(InsetGraphicsParams const & params) { - filename = igp.filename; - lyxscale = igp.lyxscale; - display = igp.display; - scale = igp.scale; - width = igp.width; - height = igp.height; - keepAspectRatio = igp.keepAspectRatio; - draft = igp.draft; - scaleBeforeRotation = igp.scaleBeforeRotation; - - bbox = igp.bbox; - clip = igp.clip; - - rotateAngle = igp.rotateAngle; - rotateOrigin = igp.rotateOrigin; - special = igp.special; - groupId = igp.groupId; + filename = params.filename; + lyxscale = params.lyxscale; + display = params.display; + scale = params.scale; + width = params.width; + height = params.height; + keepAspectRatio = params.keepAspectRatio; + draft = params.draft; + scaleBeforeRotation = params.scaleBeforeRotation; + + bbox = params.bbox; + clip = params.clip; + darkModeSensitive = params.darkModeSensitive; + + rotateAngle = params.rotateAngle; + rotateOrigin = params.rotateOrigin; + special = params.special; + groupId = params.groupId; } @@ -118,6 +121,7 @@ bool operator==(InsetGraphicsParams const & left, left.bbox == right.bbox && left.clip == right.clip && + left.darkModeSensitive == right.darkModeSensitive && left.rotateAngle == right.rotateAngle && left.rotateOrigin == right.rotateOrigin && @@ -142,6 +146,8 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const os << "\tlyxscale " << lyxscale << '\n'; if (!display) os << "\tdisplay false\n"; + if (darkModeSensitive) + os << "\tdarkModeSensitive\n"; if (!scale.empty() && !float_equal(convert(scale), 0.0, 0.05)) { if (!float_equal(convert(scale), 100.0, 0.05)) os << "\tscale " << scale << '\n'; @@ -176,18 +182,23 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const } -bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const & bufpath) +bool InsetGraphicsParams::Read(Lexer & lex, string const & token, + Buffer const & buf, bool allowOrigin) { if (token == "filename") { lex.eatLine(); - filename.set(lex.getString(), bufpath); + if (allowOrigin) + filename = buf.getReferencedFileName(lex.getString()); + else + filename.set(lex.getString(), buf.filePath()); } else if (token == "lyxscale") { lex.next(); lyxscale = lex.getInteger(); } else if (token == "display") { lex.next(); - string const type = lex.getString(); display = lex.getString() != "false"; + } else if (token == "darkModeSensitive") { + darkModeSensitive = true; } else if (token == "scale") { lex.next(); scale = lex.getString(); @@ -284,10 +295,8 @@ graphics::Params InsetGraphicsParams::as_grfxParams() const } // Paranoia check. - int const width = pars.bb.xr.inBP() - pars.bb.xl.inBP(); - int const height = pars.bb.yt.inBP() - pars.bb.yb.inBP(); - - if (width < 0 || height < 0) { + if (pars.bb.xr.inBP() < pars.bb.xl.inBP() + || pars.bb.yt.inBP() < pars.bb.yb.inBP()) { pars.bb.xl = Length(); pars.bb.xr = Length(); pars.bb.yb = Length();