2000-07-31 12:30:10 +00:00
|
|
|
/* This file is part of
|
|
|
|
* =================================================
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2000-07-31 12:30:10 +00:00
|
|
|
* LyX, The Document Processor
|
|
|
|
* Copyright 1995 Matthias Ettrich.
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
2002-01-29 09:26:24 +00:00
|
|
|
* \author Baruch Even
|
|
|
|
* \author Herbert Voss <voss@lyx.org>
|
|
|
|
*
|
2000-07-31 12:30:10 +00:00
|
|
|
* ================================================= */
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
#include <config.h>
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
2002-03-21 17:09:55 +00:00
|
|
|
#endif
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "insetgraphicsParams.h"
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
#include "graphics/GraphicsParams.h"
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "support/translator.h"
|
|
|
|
#include "support/filetools.h"
|
2001-07-28 12:24:16 +00:00
|
|
|
#include "support/lyxlib.h"
|
2001-07-30 10:50:37 +00:00
|
|
|
#include "support/LOstream.h"
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "support/LAssert.h"
|
2002-05-28 11:50:04 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "debug.h"
|
2002-07-21 21:21:06 +00:00
|
|
|
#include "lyxlex.h"
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
/// This variable keeps a tab on whether the translator was set with the
|
|
|
|
/// translations.
|
2001-03-20 01:22:46 +00:00
|
|
|
bool translatorsSet = false;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
|
|
/// This is the translator between the Display enum and corresponding lyx
|
|
|
|
/// file strings.
|
2001-03-20 01:22:46 +00:00
|
|
|
Translator< InsetGraphicsParams::DisplayType, string >
|
2002-02-01 18:53:50 +00:00
|
|
|
displayTranslator(InsetGraphicsParams::DEFAULT, "default");
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
} // namespace anon
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
InsetGraphicsParams::InsetGraphicsParams()
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
init();
|
|
|
|
// Set translators
|
|
|
|
if (! translatorsSet) {
|
|
|
|
translatorsSet = true;
|
|
|
|
// Fill the display translator
|
2002-02-01 18:53:50 +00:00
|
|
|
displayTranslator.addPair(DEFAULT, "default");
|
2000-08-14 09:44:53 +00:00
|
|
|
displayTranslator.addPair(MONOCHROME, "monochrome");
|
|
|
|
displayTranslator.addPair(GRAYSCALE, "grayscale");
|
|
|
|
displayTranslator.addPair(COLOR, "color");
|
|
|
|
displayTranslator.addPair(NONE, "none");
|
|
|
|
}
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InsetGraphicsParams::InsetGraphicsParams(InsetGraphicsParams const & igp)
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
// I decided to skip the initialization since the copy will overwrite
|
|
|
|
// everything anyway.
|
|
|
|
// init();
|
|
|
|
copy(igp);
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
InsetGraphicsParams &
|
|
|
|
InsetGraphicsParams::operator=(InsetGraphicsParams const & params)
|
2000-07-31 12:30:10 +00:00
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
// Are we assigning the object into itself?
|
|
|
|
if (this == ¶ms)
|
|
|
|
return * this;
|
|
|
|
copy(params);
|
|
|
|
return *this;
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InsetGraphicsParams::init()
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
subcaptionText = filename = string();
|
2002-01-29 09:26:24 +00:00
|
|
|
bb = string(); // bounding box
|
|
|
|
draft = false; // draft mode
|
|
|
|
clip = false; // clip image
|
2002-02-11 10:42:11 +00:00
|
|
|
display = DEFAULT; // see pref
|
2002-01-29 09:26:24 +00:00
|
|
|
subcaption = false; // subfigure
|
2002-02-11 10:42:11 +00:00
|
|
|
noUnzip = false; // unzip files
|
2002-01-29 09:26:24 +00:00
|
|
|
width = LyXLength(); // set to 0pt
|
|
|
|
height = LyXLength();
|
|
|
|
lyxwidth = LyXLength(); // for the view in lyx
|
2002-02-11 10:42:11 +00:00
|
|
|
lyxheight = LyXLength(); // also set to 0pt
|
|
|
|
scale = 0; // unit is %
|
|
|
|
lyxscale = 0; // same for lyxview
|
2002-07-22 12:36:41 +00:00
|
|
|
size_kind = DEFAULT_SIZE; // do nothing
|
|
|
|
lyxsize_kind = DEFAULT_SIZE; // do nothing
|
|
|
|
keepAspectRatio = false; // for latex
|
|
|
|
keepLyXAspectRatio = false; // for lyx
|
2002-03-21 17:09:55 +00:00
|
|
|
rotate = false; // Rotating
|
2002-07-22 12:36:41 +00:00
|
|
|
rotateOrigin = "leftBaseline"; // Origin
|
2002-01-29 09:26:24 +00:00
|
|
|
rotateAngle = 0.0; // in degrees
|
|
|
|
special = string(); // userdefined stuff
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
filename = igp.filename;
|
2002-01-29 09:26:24 +00:00
|
|
|
bb = igp.bb;
|
|
|
|
draft = igp.draft;
|
|
|
|
clip = igp.clip;
|
2000-08-14 09:44:53 +00:00
|
|
|
display = igp.display;
|
|
|
|
subcaption = igp.subcaption;
|
|
|
|
subcaptionText = igp.subcaptionText;
|
2002-02-11 10:42:11 +00:00
|
|
|
noUnzip = igp.noUnzip;
|
2000-08-14 09:44:53 +00:00
|
|
|
keepAspectRatio = igp.keepAspectRatio;
|
2002-01-29 09:26:24 +00:00
|
|
|
width = igp.width;
|
|
|
|
height = igp.height;
|
|
|
|
scale = igp.scale;
|
2002-07-22 12:36:41 +00:00
|
|
|
size_kind = igp.size_kind;
|
|
|
|
lyxsize_kind = igp.lyxsize_kind;
|
2002-01-29 09:26:24 +00:00
|
|
|
lyxwidth = igp.lyxwidth;
|
|
|
|
lyxheight = igp.lyxheight;
|
2002-07-19 21:44:14 +00:00
|
|
|
keepLyXAspectRatio = igp.keepLyXAspectRatio;
|
2002-02-05 12:19:32 +00:00
|
|
|
lyxscale = igp.lyxscale;
|
2002-07-22 12:36:41 +00:00
|
|
|
keepLyXAspectRatio = igp.keepLyXAspectRatio;
|
2002-02-05 18:43:28 +00:00
|
|
|
rotate = igp.rotate;
|
2000-08-14 09:44:53 +00:00
|
|
|
rotateOrigin = igp.rotateOrigin;
|
|
|
|
rotateAngle = igp.rotateAngle;
|
2002-01-29 09:26:24 +00:00
|
|
|
special = igp.special;
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
bool operator==(InsetGraphicsParams const & left,
|
2002-03-21 17:09:55 +00:00
|
|
|
InsetGraphicsParams const & right)
|
2000-07-31 12:30:10 +00:00
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
if (left.filename == right.filename &&
|
2002-05-01 10:23:51 +00:00
|
|
|
left.bb == right.bb &&
|
|
|
|
left.draft == right.draft &&
|
|
|
|
left.clip == right.clip &&
|
|
|
|
left.display == right.display &&
|
|
|
|
left.subcaption == right.subcaption &&
|
|
|
|
left.noUnzip == right.noUnzip &&
|
|
|
|
left.subcaptionText == right.subcaptionText &&
|
|
|
|
left.keepAspectRatio == right.keepAspectRatio &&
|
|
|
|
left.width == right.width &&
|
|
|
|
left.height == right.height &&
|
|
|
|
left.scale == right.scale &&
|
2002-07-22 12:36:41 +00:00
|
|
|
left.size_kind == right.size_kind &&
|
|
|
|
left.lyxsize_kind == right.lyxsize_kind &&
|
2002-05-01 10:23:51 +00:00
|
|
|
left.lyxwidth == right.lyxwidth &&
|
|
|
|
left.lyxheight == right.lyxheight &&
|
2002-07-19 21:44:14 +00:00
|
|
|
left.keepLyXAspectRatio == right.keepLyXAspectRatio &&
|
2002-05-01 10:23:51 +00:00
|
|
|
left.lyxscale == right.lyxscale &&
|
2002-07-22 12:36:41 +00:00
|
|
|
left.keepLyXAspectRatio == right.keepLyXAspectRatio &&
|
2002-05-01 10:23:51 +00:00
|
|
|
left.rotate == right.rotate &&
|
|
|
|
left.rotateOrigin == right.rotateOrigin &&
|
|
|
|
lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 &&
|
|
|
|
left.special == right.special)
|
|
|
|
)
|
2000-08-14 09:44:53 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 13:16:37 +00:00
|
|
|
bool operator!=(InsetGraphicsParams const & left,
|
2002-03-21 17:09:55 +00:00
|
|
|
InsetGraphicsParams const & right)
|
2001-03-28 13:16:37 +00:00
|
|
|
{
|
2002-03-21 17:09:55 +00:00
|
|
|
return !(left == right);
|
2001-03-28 13:16:37 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2002-07-22 12:36:41 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
InsetGraphicsParams::sizeKind getSizeKind(string const & str_in)
|
|
|
|
{
|
|
|
|
if (str_in == "width_height")
|
|
|
|
return InsetGraphicsParams::WH;
|
|
|
|
if (str_in == "scale")
|
|
|
|
return InsetGraphicsParams::SCALE;
|
|
|
|
|
|
|
|
// all other like "original"
|
|
|
|
return InsetGraphicsParams::DEFAULT_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const getSizeKindStr(InsetGraphicsParams::sizeKind sK_in)
|
|
|
|
{
|
|
|
|
if (sK_in == InsetGraphicsParams::SCALE)
|
|
|
|
return "scale";
|
|
|
|
if (sK_in == InsetGraphicsParams::WH)
|
|
|
|
return "width_height";
|
|
|
|
|
|
|
|
// all other like DEFAULT_SIZE"
|
|
|
|
return "original";
|
|
|
|
}
|
|
|
|
|
2002-08-12 16:41:15 +00:00
|
|
|
// compatibility-stuff 1.20->1.3.0
|
|
|
|
InsetGraphicsParams::sizeKind getSizeKind(int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case 1:
|
|
|
|
return InsetGraphicsParams::WH;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return InsetGraphicsParams::SCALE;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return InsetGraphicsParams::DEFAULT_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-22 12:36:41 +00:00
|
|
|
} //anon
|
|
|
|
|
|
|
|
|
2002-03-25 11:04:34 +00:00
|
|
|
void InsetGraphicsParams::Write(ostream & os) const
|
2000-07-31 12:30:10 +00:00
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
// If there is no filename, write nothing for it.
|
2002-03-25 11:04:34 +00:00
|
|
|
if (!filename.empty()) {
|
|
|
|
os << "\tfilename " << filename << '\n';
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
if (!bb.empty()) // bounding box
|
|
|
|
os << "\tBoundingBox " << bb << '\n';
|
|
|
|
if (clip) // clip image
|
|
|
|
os << "\tclip\n";
|
|
|
|
if (draft) // draft mode
|
|
|
|
os << "\tdraft\n";
|
2002-02-11 10:42:11 +00:00
|
|
|
// Save the display type for the view inside lyx
|
2002-01-29 09:26:24 +00:00
|
|
|
os << "\tdisplay " << displayTranslator.find(display) << '\n';
|
2000-08-14 09:44:53 +00:00
|
|
|
// Save the subcaption status
|
|
|
|
if (subcaption)
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tsubcaption\n";
|
2002-01-29 09:26:24 +00:00
|
|
|
if (!subcaptionText.empty())
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n';
|
2002-02-11 10:42:11 +00:00
|
|
|
if (noUnzip)
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tnoUnzip\n";
|
2002-07-22 12:36:41 +00:00
|
|
|
os << "\tsize_kind " << getSizeKindStr(size_kind) << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
if (!width.zero())
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\twidth " << width.asString() << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
if (!height.zero())
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\theight " << height.asString() << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
if (scale != 0)
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tscale " << scale << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
if (keepAspectRatio)
|
|
|
|
os << "\tkeepAspectRatio\n";
|
2002-02-05 18:43:28 +00:00
|
|
|
if (rotate)
|
|
|
|
os << "\trotate\n";
|
2002-04-11 18:40:59 +00:00
|
|
|
if (rotateAngle != 0.0)
|
2002-01-29 09:26:24 +00:00
|
|
|
os << "\trotateAngle " << rotateAngle << '\n';
|
|
|
|
if (!rotateOrigin.empty())
|
|
|
|
os << "\trotateOrigin " << rotateOrigin << '\n';
|
|
|
|
if (!special.empty())
|
|
|
|
os << "\tspecial " << special << '\n';
|
2002-02-11 10:42:11 +00:00
|
|
|
// the values for the view in lyx
|
2002-07-22 12:36:41 +00:00
|
|
|
os << "\tlyxsize_kind " << getSizeKindStr(lyxsize_kind) << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
if (!lyxwidth.zero()) // the lyx-viewsize
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tlyxwidth " << lyxwidth.asString() << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
if (!lyxheight.zero())
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tlyxheight " << lyxheight.asString();
|
2002-07-19 21:44:14 +00:00
|
|
|
if (keepLyXAspectRatio)
|
|
|
|
os << "\tkeepLyXAspectRatio\n";
|
2002-02-05 12:19:32 +00:00
|
|
|
if (lyxscale != 0)
|
2002-05-01 10:23:51 +00:00
|
|
|
os << "\tlyxscale " << lyxscale << '\n';
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2000-11-15 03:22:08 +00:00
|
|
|
|
2002-05-23 09:21:32 +00:00
|
|
|
bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
|
2000-07-31 12:30:10 +00:00
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
if (token == "filename") {
|
2002-05-29 22:07:59 +00:00
|
|
|
lex.eatLine();
|
2001-08-06 19:13:25 +00:00
|
|
|
filename = lex.getString();
|
2002-01-29 09:26:24 +00:00
|
|
|
} else if (token == "BoundingBox") {
|
|
|
|
for (int i=0; i<4 ;i++) {
|
2002-05-01 10:23:51 +00:00
|
|
|
lex.next();
|
|
|
|
bb += (lex.getString()+" ");
|
2002-01-29 09:26:24 +00:00
|
|
|
}
|
|
|
|
} else if (token == "clip") {
|
|
|
|
clip = true;
|
|
|
|
} else if (token == "draft") {
|
|
|
|
draft = true;
|
2000-08-14 09:44:53 +00:00
|
|
|
} else if (token == "display") {
|
|
|
|
lex.next();
|
2002-03-26 12:17:04 +00:00
|
|
|
string const type = lex.getString();
|
|
|
|
display = displayTranslator.find(type);
|
2000-08-14 09:44:53 +00:00
|
|
|
} else if (token == "subcaption") {
|
|
|
|
subcaption = true;
|
|
|
|
} else if (token == "subcaptionText") {
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
subcaptionText = lex.getString();
|
2002-02-11 10:42:11 +00:00
|
|
|
} else if (token == "noUnzip") {
|
|
|
|
noUnzip = true;
|
2002-07-23 12:20:21 +00:00
|
|
|
} else if (token == "size_kind") {
|
2000-08-14 09:44:53 +00:00
|
|
|
lex.next();
|
2002-07-22 12:36:41 +00:00
|
|
|
size_kind = getSizeKind(lex.getString());
|
2002-07-23 12:20:21 +00:00
|
|
|
// compatibility-stuff 1.20->1.3.0
|
|
|
|
} else if (token == "size_type") {
|
|
|
|
lex.next();
|
2002-08-12 16:41:15 +00:00
|
|
|
size_kind = getSizeKind(lex.getInteger());
|
2000-08-14 09:44:53 +00:00
|
|
|
} else if (token == "width") {
|
|
|
|
lex.next();
|
2002-01-29 09:26:24 +00:00
|
|
|
width = LyXLength(lex.getString());
|
2000-08-14 09:44:53 +00:00
|
|
|
} else if (token == "height") {
|
|
|
|
lex.next();
|
2002-01-29 09:26:24 +00:00
|
|
|
height = LyXLength(lex.getString());
|
|
|
|
} else if (token == "keepAspectRatio") {
|
|
|
|
keepAspectRatio = true;
|
2002-01-31 14:20:09 +00:00
|
|
|
} else if (token == "scale") {
|
|
|
|
lex.next();
|
|
|
|
scale = lex.getInteger();
|
2002-02-05 18:43:28 +00:00
|
|
|
} else if (token == "rotate") {
|
|
|
|
rotate = true;
|
2000-08-14 09:44:53 +00:00
|
|
|
} else if (token == "rotateAngle") {
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
rotateAngle = lex.getFloat();
|
2002-01-29 09:26:24 +00:00
|
|
|
} else if (token == "rotateOrigin") {
|
|
|
|
lex.next();
|
|
|
|
rotateOrigin=lex.getString();
|
2002-07-22 12:36:41 +00:00
|
|
|
} else if (token == "lyxsize_kind") {
|
2002-02-05 12:19:32 +00:00
|
|
|
lex.next();
|
2002-07-22 12:36:41 +00:00
|
|
|
lyxsize_kind = getSizeKind(lex.getString());
|
2002-08-12 16:41:15 +00:00
|
|
|
// compatibility-stuff 1.20->1.3.0
|
|
|
|
} else if (token == "lyxsize_type") {
|
|
|
|
lex.next();
|
|
|
|
lyxsize_kind = getSizeKind(lex.getInteger());
|
2002-01-29 09:26:24 +00:00
|
|
|
} else if (token == "lyxwidth") {
|
|
|
|
lex.next();
|
|
|
|
lyxwidth = LyXLength(lex.getString());
|
|
|
|
} else if (token == "lyxheight") {
|
|
|
|
lex.next();
|
|
|
|
lyxheight = LyXLength(lex.getString());
|
2002-07-19 21:44:14 +00:00
|
|
|
} else if (token == "keepLyXAspectRatio") {
|
|
|
|
keepLyXAspectRatio = true;
|
2002-02-05 12:19:32 +00:00
|
|
|
} else if (token == "lyxscale") {
|
|
|
|
lex.next();
|
|
|
|
lyxscale = lex.getInteger();
|
2002-04-08 14:47:21 +00:00
|
|
|
} else if (token == "special") {
|
|
|
|
lex.eatLine();
|
|
|
|
special = lex.getString();
|
2002-02-11 10:42:11 +00:00
|
|
|
} else { // If it's none of the above, its not ours.
|
2000-08-14 09:44:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
2002-05-28 11:50:04 +00:00
|
|
|
|
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
grfx::Params InsetGraphicsParams::as_grfxParams(string const & filepath) const
|
2002-05-28 11:50:04 +00:00
|
|
|
{
|
2002-06-28 11:22:56 +00:00
|
|
|
grfx::Params pars;
|
2002-05-28 11:50:04 +00:00
|
|
|
pars.width = 0;
|
|
|
|
pars.height = 0;
|
|
|
|
pars.scale = 0;
|
2002-07-21 15:51:07 +00:00
|
|
|
pars.keepLyXAspectRatio = false;
|
2002-05-28 11:50:04 +00:00
|
|
|
pars.angle = 0;
|
|
|
|
pars.filename = filename;
|
|
|
|
|
|
|
|
if (!filepath.empty()) {
|
|
|
|
pars.filename = MakeAbsPath(pars.filename, filepath);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clip) {
|
|
|
|
pars.bb = bb;
|
|
|
|
|
|
|
|
// Get the original Bounding Box from the file
|
|
|
|
string const tmp = readBB_from_PSFile(filename);
|
|
|
|
lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
|
|
|
|
if (!tmp.empty()) {
|
|
|
|
int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
|
|
|
|
int const bb_orig_yb = strToInt(token(tmp, ' ', 1));
|
|
|
|
|
|
|
|
pars.bb.xl -= bb_orig_xl;
|
|
|
|
pars.bb.xr -= bb_orig_xl;
|
|
|
|
pars.bb.yb -= bb_orig_yb;
|
|
|
|
pars.bb.yt -= bb_orig_yb;
|
|
|
|
}
|
|
|
|
|
|
|
|
pars.bb.xl = std::max(0, pars.bb.xl);
|
|
|
|
pars.bb.xr = std::max(0, pars.bb.xr);
|
|
|
|
pars.bb.yb = std::max(0, pars.bb.yb);
|
|
|
|
pars.bb.yt = std::max(0, pars.bb.yt);
|
|
|
|
|
|
|
|
// Paranoia check.
|
|
|
|
int const width = pars.bb.xr - pars.bb.xl;
|
|
|
|
int const height = pars.bb.yt - pars.bb.yb;
|
|
|
|
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
pars.bb.xl = 0;
|
|
|
|
pars.bb.xr = 0;
|
|
|
|
pars.bb.yb = 0;
|
|
|
|
pars.bb.yt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rotate)
|
|
|
|
pars.angle = int(rotateAngle);
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
switch (display) {
|
|
|
|
case InsetGraphicsParams::NONE:
|
2002-06-26 14:15:08 +00:00
|
|
|
pars.display = grfx::NoDisplay;
|
2002-07-21 15:51:07 +00:00
|
|
|
break;
|
2002-05-28 11:50:04 +00:00
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
case InsetGraphicsParams::MONOCHROME:
|
|
|
|
pars.display = grfx::MonochromeDisplay;
|
|
|
|
break;
|
2002-05-28 11:50:04 +00:00
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
case InsetGraphicsParams::GRAYSCALE:
|
|
|
|
pars.display = grfx::GrayscaleDisplay;
|
2002-05-28 11:50:04 +00:00
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
case InsetGraphicsParams::COLOR:
|
|
|
|
pars.display = grfx::ColorDisplay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: {
|
|
|
|
if (lyxrc.display_graphics == "mono")
|
|
|
|
pars.display = grfx::MonochromeDisplay;
|
|
|
|
else if (lyxrc.display_graphics == "gray")
|
|
|
|
pars.display = grfx::GrayscaleDisplay;
|
|
|
|
else if (lyxrc.display_graphics == "color")
|
|
|
|
pars.display = grfx::ColorDisplay;
|
|
|
|
else
|
|
|
|
pars.display = grfx::NoDisplay;
|
|
|
|
}
|
2002-05-28 11:50:04 +00:00
|
|
|
}
|
2002-07-21 15:51:07 +00:00
|
|
|
|
2002-05-28 11:50:04 +00:00
|
|
|
// Override the above if we're not using a gui
|
|
|
|
if (!lyxrc.use_gui) {
|
2002-06-26 14:15:08 +00:00
|
|
|
pars.display = grfx::NoDisplay;
|
2002-05-28 11:50:04 +00:00
|
|
|
}
|
2002-07-22 12:36:41 +00:00
|
|
|
|
|
|
|
if (lyxsize_kind == InsetGraphicsParams::SCALE) {
|
2002-05-28 11:50:04 +00:00
|
|
|
pars.scale = lyxscale;
|
2002-07-22 12:36:41 +00:00
|
|
|
|
|
|
|
} else if (lyxsize_kind == InsetGraphicsParams::WH) {
|
2002-07-21 15:51:07 +00:00
|
|
|
pars.width = lyxwidth.inBP();
|
|
|
|
pars.height = lyxheight.inBP();
|
|
|
|
pars.keepLyXAspectRatio = keepLyXAspectRatio;
|
2002-07-22 12:36:41 +00:00
|
|
|
}
|
2002-07-19 21:44:14 +00:00
|
|
|
|
2002-05-28 11:50:04 +00:00
|
|
|
return pars;
|
|
|
|
}
|