]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetGraphicsParams.cpp
Improved character count statistics for letter based insets (e.g. the LyX logo).
[features.git] / src / insets / InsetGraphicsParams.cpp
index 15d6cad7a4a1324173a414e0ce4a71df4e9d8c0b..9f55246098e39638cd061f2625e5c2fac8bc41ee 100644 (file)
@@ -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 == &params)
-               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();
@@ -176,17 +177,20 @@ 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 == "scale") {
                lex.next();
@@ -284,10 +288,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();