#include "LyXRC.h"
#include "graphics/epstools.h"
-#include "graphics/GraphicsParams.h"
#include "graphics/GraphicsTypes.h"
#include "support/convert.h"
}
-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;
}
draft = false; // draft mode
scaleBeforeRotation = false; // scale image before rotating
- bb = string(); // bounding box
+ bbox = graphics::BoundingBox(); // bounding box
clip = false; // clip image
rotateAngle = "0"; // angle of rotation in degrees
draft = igp.draft;
scaleBeforeRotation = igp.scaleBeforeRotation;
- bb = igp.bb;
+ bbox = igp.bbox;
clip = igp.clip;
rotateAngle = igp.rotateAngle;
left.draft == right.draft &&
left.scaleBeforeRotation == right.scaleBeforeRotation &&
- left.bb == right.bb &&
+ left.bbox == right.bbox &&
left.clip == right.clip &&
left.rotateAngle == right.rotateAngle &&
if (scaleBeforeRotation)
os << "\tscaleBeforeRotation\n";
- if (!bb.empty()) // bounding box
- os << "\tBoundingBox " << bb << '\n';
+ if (!bbox.empty()) // bounding box
+ os << "\tBoundingBox " << bbox << '\n';
if (clip) // clip image
os << "\tclip\n";
}
-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 == "scale") {
lex.next();
} else if (token == "scaleBeforeRotation") {
scaleBeforeRotation = true;
} else if (token == "BoundingBox") {
- bb.erase();
- for (int i = 0; i < 4; ++i) {
- if (i != 0)
- bb += ' ';
- lex.next();
- bb += lex.getString();
- }
+ lex.next();
+ bbox.xl = Length(lex.getString());
+ lex.next();
+ bbox.yb = Length(lex.getString());
+ lex.next();
+ bbox.xr = Length(lex.getString());
+ lex.next();
+ bbox.yt = Length(lex.getString());
} else if (token == "clip") {
clip = true;
} else if (token == "rotateAngle") {
pars.angle = convert<double>(rotateAngle);
if (clip) {
- pars.bb = bb;
+ pars.bb = bbox;
// Get the original Bounding Box from the file
string const tmp = graphics::readBB_from_PSFile(filename);
}
// 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();