]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsParams.cpp
Fix #7720: plain text export of branches should contain only content of the inset.
[lyx.git] / src / graphics / GraphicsParams.cpp
1 /**
2  * \file GraphicsParams.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GraphicsParams.h"
14
15 #include "Length.h"
16
17 #include <cstdlib>
18 #include <sstream>
19
20 using namespace std;
21
22 namespace lyx {
23 namespace graphics {
24
25 Params::Params()
26         : display(true),
27           scale(100),
28           angle(0)
29 {}
30
31
32 bool operator==(Params const & a, Params const & b)
33 {
34         return (a.filename == b.filename &&
35                 a.display == b.display &&
36                 a.bb == b.bb &&
37                 a.scale == b.scale &&
38                 a.angle == b.angle);
39 }
40
41
42 bool operator!=(Params const & a, Params const & b)
43 {
44         return !(a == b);
45 }
46
47
48 ostream & operator<<(ostream & os, BoundingBox const & bb)
49 {
50         os << bb.xl << ' ' << bb.yb << ' ' << bb.xr << ' ' << bb.yt;
51         return os;
52 }
53
54
55 BoundingBox::BoundingBox()
56         : xl(0), yb(0), xr(0), yt(0)
57 {}
58
59
60 BoundingBox::BoundingBox(string const & bb)
61         : xl(0), yb(0), xr(0), yt(0)
62 {
63         if (bb.empty())
64                 return;
65
66         istringstream is(bb.c_str());
67         string a, b, c, d;
68         is >> a >> b >> c >> d;
69
70         // inBP returns the length in Postscript points.
71         // Note further that there are 72 Postscript pixels per inch.
72         unsigned int const xl_tmp = abs(Length(a).inBP());
73         unsigned int const yb_tmp = abs(Length(b).inBP());
74         unsigned int const xr_tmp = abs(Length(c).inBP());
75         unsigned int const yt_tmp = abs(Length(d).inBP());
76
77         if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
78                 return;
79
80         xl = xl_tmp;
81         yb = yb_tmp;
82         xr = xr_tmp;
83         yt = yt_tmp;
84 }
85
86
87 bool BoundingBox::empty() const
88 {
89         return (!xl && !yb && !xr && !yt);
90 }
91
92
93 bool operator==(BoundingBox const & a, BoundingBox const & b)
94 {
95         return (a.xl == b.xl &&
96                 a.yb == b.yb &&
97                 a.xr == b.xr &&
98                 a.yt == b.yt);
99 }
100
101
102 bool operator!=(BoundingBox const & a, BoundingBox const & b)
103 {
104         return !(a == b);
105 }
106
107 } // namespace graphics
108 } // namespace lyx