]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphicsParams.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insetgraphicsParams.C
index 53c5647d5a35a589782bc43ad4f54f9fb7a225c0..0423356447183e4a6c17cdcde2f5611f50daa5a7 100644 (file)
@@ -6,7 +6,7 @@
  * \author Baruch Even
  * \author Herbert Voss
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
@@ -21,6 +21,7 @@
 #include "support/LOstream.h"
 #include "support/LAssert.h"
 #include "support/lstrings.h"
+#include "support/translator.h"
 #include "lyxrc.h"
 #include "debug.h"
 #include "lyxlex.h"
@@ -30,6 +31,13 @@ using namespace lyx::support;
 
 using std::ostream;
 
+namespace lyx {
+namespace graphics {
+/// The translator between the DisplayType and the corresponding lyx string.
+extern Translator<DisplayType, string> displayTranslator;
+}
+}
+
 
 InsetGraphicsParams::InsetGraphicsParams()
 {
@@ -61,7 +69,7 @@ void InsetGraphicsParams::init()
 {
        filename.erase();
        lyxscale = 100;                 // lyx scaling in percentage
-       display = grfx::DefaultDisplay; // display mode; see preferences
+       display = lyx::graphics::DefaultDisplay; // display mode; see preferences
        scale = 100.0;                  // output scaling in percentage
        width = LyXLength();
        height = LyXLength();
@@ -144,12 +152,12 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
        // Do not write the default values
 
        if (!filename.empty()) {
-               os << "\tfilename " << MakeRelPath(filename, bufpath) << '\n';
+               os << "\tfilename " << filename.outputFilename(bufpath) << '\n';
        }
        if (lyxscale != 100)
                os << "\tlyxscale " << lyxscale << '\n';
-       if (display != grfx::DefaultDisplay)
-               os << "\tdisplay " << grfx::displayTranslator.find(display) << '\n';
+       if (display != lyx::graphics::DefaultDisplay)
+               os << "\tdisplay " << lyx::graphics::displayTranslator.find(display) << '\n';
        if (!float_equal(scale, 0.0, 0.05)) {
                if (!float_equal(scale, 100.0, 0.05))
                        os << "\tscale " << scale << '\n';
@@ -189,14 +197,14 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
 {
        if (token == "filename") {
                lex.eatLine();
-               filename = MakeAbsPath(lex.getString(), bufpath);
+               filename.set(lex.getString(), bufpath);
        } else if (token == "lyxscale") {
                lex.next();
                lyxscale = lex.getInteger();
        } else if (token == "display") {
                lex.next();
                string const type = lex.getString();
-               display = grfx::displayTranslator.find(type);
+               display = lyx::graphics::displayTranslator.find(type);
        } else if (token == "scale") {
                lex.next();
                scale = lex.getFloat();
@@ -256,10 +264,10 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
 }
 
 
-grfx::Params InsetGraphicsParams::as_grfxParams() const
+lyx::graphics::Params InsetGraphicsParams::as_grfxParams() const
 {
-       grfx::Params pars;
-       pars.filename = filename;
+       lyx::graphics::Params pars;
+       pars.filename = filename.absFilename();
        pars.scale = lyxscale;
        pars.angle = rotateAngle;
 
@@ -267,7 +275,7 @@ grfx::Params InsetGraphicsParams::as_grfxParams() const
                pars.bb = bb;
 
                // Get the original Bounding Box from the file
-               string const tmp = readBB_from_PSFile(filename);
+               string const tmp = readBB_from_PSFile(filename.absFilename());
                lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
                if (!tmp.empty()) {
                        unsigned int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
@@ -307,7 +315,7 @@ grfx::Params InsetGraphicsParams::as_grfxParams() const
                }
        }
 
-       if (display == grfx::DefaultDisplay) {
+       if (display == lyx::graphics::DefaultDisplay) {
                pars.display = lyxrc.display_graphics;
        } else {
                pars.display = display;
@@ -315,7 +323,7 @@ grfx::Params InsetGraphicsParams::as_grfxParams() const
 
        // Override the above if we're not using a gui
        if (!lyx_gui::use_gui) {
-               pars.display = grfx::NoDisplay;
+               pars.display = lyx::graphics::NoDisplay;
        }
 
        return pars;