mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-21 05:00:59 +00:00
4a1be58591
- the display combo in the prefs, external and graphics dialogs are gone - the lyxrc display_graphics option now overrides any local inset display option - The external template format has a new tag: Preview - format incremented to 337 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25245 a592a061-630c-0410-9148-cb99ea01b6c8
109 lines
1.9 KiB
C++
109 lines
1.9 KiB
C++
/**
|
|
* \file GraphicsParams.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Angus Leeming
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "GraphicsParams.h"
|
|
|
|
#include "Length.h"
|
|
|
|
#include <cstdlib>
|
|
#include <sstream>
|
|
|
|
using namespace std;
|
|
|
|
namespace lyx {
|
|
namespace graphics {
|
|
|
|
Params::Params()
|
|
: display(true),
|
|
scale(100),
|
|
angle(0)
|
|
{}
|
|
|
|
|
|
bool operator==(Params const & a, Params const & b)
|
|
{
|
|
return (a.filename == b.filename &&
|
|
a.display == b.display &&
|
|
a.bb == b.bb &&
|
|
a.scale == b.scale &&
|
|
a.angle == b.angle);
|
|
}
|
|
|
|
|
|
bool operator!=(Params const & a, Params const & b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
|
|
ostream & operator<<(ostream & os, BoundingBox const & bb)
|
|
{
|
|
os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt;
|
|
return os;
|
|
}
|
|
|
|
|
|
BoundingBox::BoundingBox()
|
|
: xl(0), yb(0), xr(0), yt(0)
|
|
{}
|
|
|
|
|
|
BoundingBox::BoundingBox(string const & bb)
|
|
: xl(0), yb(0), xr(0), yt(0)
|
|
{
|
|
if (bb.empty())
|
|
return;
|
|
|
|
istringstream is(bb.c_str());
|
|
string a, b, c, d;
|
|
is >> a >> b >> c >> d;
|
|
|
|
// inBP returns the length in Postscript points.
|
|
// Note further that there are 72 Postscript pixels per inch.
|
|
unsigned int const xl_tmp = abs(Length(a).inBP());
|
|
unsigned int const yb_tmp = abs(Length(b).inBP());
|
|
unsigned int const xr_tmp = abs(Length(c).inBP());
|
|
unsigned int const yt_tmp = abs(Length(d).inBP());
|
|
|
|
if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
|
|
return;
|
|
|
|
xl = xl_tmp;
|
|
yb = yb_tmp;
|
|
xr = xr_tmp;
|
|
yt = yt_tmp;
|
|
}
|
|
|
|
|
|
bool BoundingBox::empty() const
|
|
{
|
|
return (!xl && !yb && !xr && !yt);
|
|
}
|
|
|
|
|
|
bool operator==(BoundingBox const & a, BoundingBox const & b)
|
|
{
|
|
return (a.xl == b.xl &&
|
|
a.yb == b.yb &&
|
|
a.xr == b.xr &&
|
|
a.yt == b.yt);
|
|
}
|
|
|
|
|
|
bool operator!=(BoundingBox const & a, BoundingBox const & b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
} // namespace graphics
|
|
} // namespace lyx
|