]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsConverter.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / graphics / GraphicsConverter.cpp
index 4af897fc08a5b852b08bfc993e81f1e98ded14eb..c5c63b44eee68f7aa9dbd83f3974a777eae6cdd6 100644 (file)
@@ -15,7 +15,7 @@
 #include "Converter.h"
 #include "Format.h"
 
-#include "support/assert.h"
+#include "support/lassert.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/FileName.h"
@@ -260,7 +260,7 @@ static void build_script(FileName const & from_file,
 {
        LASSERT(from_format != to_format, /**/);
        LYXERR(Debug::GRAPHICS, "build_script ... ");
-       typedef Converters::EdgePath EdgePath;
+       typedef Graph::EdgePath EdgePath;
 
        script << "#!/usr/bin/env python\n"
                  "# -*- coding: utf-8 -*-\n"
@@ -295,7 +295,6 @@ static void build_script(FileName const & from_file,
        static int counter = 0;
        string const tmp = "gconvert" + convert<string>(counter++);
        FileName const to_base = FileName::tempName(tmp);
-       to_base.removeFile();
 
        // Create a copy of the file in case the original name contains
        // problematic characters like ' or ". We can work around that problem
@@ -346,10 +345,11 @@ static void build_script(FileName const & from_file,
        }
 
        // The conversion commands may contain these tokens that need to be
-       // changed to infile, infile_base, outfile respectively.
-       string const token_from = "$$i";
-       string const token_base = "$$b";
-       string const token_to   = "$$o";
+       // changed to infile, infile_base, outfile and output directory respectively.
+       string const token_from  = "$$i";
+       string const token_base  = "$$b";
+       string const token_to    = "$$o";
+       string const token_todir = "$$d";
 
        EdgePath::const_iterator it  = edgepath.begin();
        EdgePath::const_iterator end = edgepath.end();
@@ -368,14 +368,16 @@ static void build_script(FileName const & from_file,
                          "infile_base = utf8ToDefaultEncoding("
                                << quoteName(infile_base, quote_python) << ")\n"
                          "outfile = utf8ToDefaultEncoding("
-                               << quoteName(outfile, quote_python) << ")\n";
+                               << quoteName(outfile, quote_python) << ")\n"
+                         "outdir  = os.path.dirname(outfile)\n" ;
 
                // See comment about extra " quotes above (although that
                // applies only for the first loop run here).
                string command = conv.command;
-               command = subst(command, token_from, "' + '\"' + infile + '\"' + '");
-               command = subst(command, token_base, "' + '\"' + infile_base + '\"' + '");
-               command = subst(command, token_to,   "' + '\"' + outfile + '\"' + '");
+               command = subst(command, token_from,  "' + '\"' + infile + '\"' + '");
+               command = subst(command, token_base,  "' + '\"' + infile_base + '\"' + '");
+               command = subst(command, token_to,    "' + '\"' + outfile + '\"' + '");
+               command = subst(command, token_todir, "' + '\"' + outdir + '\"' + '");
                command = libScriptSearch(command, quote_python);
 
                build_conversion_command(command, script);