]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphicsParams.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetgraphicsParams.C
index 875b332223e37ec35126b36b2029058bd7bfc16e..c0cdd5fae8826669aa6d68d3e2c1ae08c78acc69 100644 (file)
@@ -14,6 +14,7 @@
 #include "insetgraphicsParams.h"
 
 #include "debug.h"
+#include "lyx_main.h" // for use_gui
 #include "lyxlex.h"
 #include "lyxrc.h"
 
 #include "support/lstrings.h"
 #include "support/translator.h"
 
-using lyx::support::float_equal;
-using lyx::support::readBB_from_PSFile;
-using lyx::support::token;
+
+namespace lyx {
+
+using support::float_equal;
+using support::readBB_from_PSFile;
+using support::token;
 
 using std::string;
 using std::ostream;
 
 
-namespace lyx {
-extern bool use_gui;
-}
-
 InsetGraphicsParams::InsetGraphicsParams()
 {
        init();
@@ -67,7 +67,7 @@ void InsetGraphicsParams::init()
 {
        filename.erase();
        lyxscale = 100;                 // lyx scaling in percentage
-       display = lyx::graphics::DefaultDisplay; // display mode; see preferences
+       display = graphics::DefaultDisplay; // display mode; see preferences
        scale = string();                       // output scaling in percentage
        width = LyXLength();
        height = LyXLength();
@@ -154,8 +154,8 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
        }
        if (lyxscale != 100)
                os << "\tlyxscale " << lyxscale << '\n';
-       if (display != lyx::graphics::DefaultDisplay)
-               os << "\tdisplay " << lyx::graphics::displayTranslator().find(display) << '\n';
+       if (display != graphics::DefaultDisplay)
+               os << "\tdisplay " << graphics::displayTranslator().find(display) << '\n';
        if (!scale.empty() && !float_equal(convert<double>(scale), 0.0, 0.05)) {
                if (!float_equal(convert<double>(scale), 100.0, 0.05))
                        os << "\tscale " << scale << '\n';
@@ -203,7 +203,7 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
        } else if (token == "display") {
                lex.next();
                string const type = lex.getString();
-               display = lyx::graphics::displayTranslator().find(type);
+               display = graphics::displayTranslator().find(type);
        } else if (token == "scale") {
                lex.next();
                scale = lex.getString();
@@ -263,10 +263,10 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
 }
 
 
-lyx::graphics::Params InsetGraphicsParams::as_grfxParams() const
+graphics::Params InsetGraphicsParams::as_grfxParams() const
 {
-       lyx::graphics::Params pars;
-       pars.filename = filename.absFilename();
+       graphics::Params pars;
+       pars.filename = filename;
        pars.scale = lyxscale;
        pars.angle = convert<double>(rotateAngle);
 
@@ -274,7 +274,7 @@ lyx::graphics::Params InsetGraphicsParams::as_grfxParams() const
                pars.bb = bb;
 
                // Get the original Bounding Box from the file
-               string const tmp = readBB_from_PSFile(filename.absFilename());
+               string const tmp = readBB_from_PSFile(filename);
                lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
                if (!tmp.empty()) {
 #ifdef WITH_WARNINGS
@@ -317,16 +317,19 @@ lyx::graphics::Params InsetGraphicsParams::as_grfxParams() const
                }
        }
 
-       if (display == lyx::graphics::DefaultDisplay) {
+       if (display == graphics::DefaultDisplay) {
                pars.display = lyxrc.display_graphics;
        } else {
                pars.display = display;
        }
 
        // Override the above if we're not using a gui
-       if (!lyx::use_gui) {
-               pars.display = lyx::graphics::NoDisplay;
+       if (!use_gui) {
+               pars.display = graphics::NoDisplay;
        }
 
        return pars;
 }
+
+
+} // namespace lyx