]> git.lyx.org Git - lyx.git/blobdiff - src/converter.C
Collapse all those LFUN_XYZ_APPLY to a single LFUN_INSET_APPLY.
[lyx.git] / src / converter.C
index 17e07d7d8a59c7a227ea0b02a0ac52e2ac1e4c54..e1a96bc14471834f9a80038b6bbe012986bdbd29 100644 (file)
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "converter.h"
 #include "lyxrc.h"
 #include "buffer.h"
@@ -123,6 +119,8 @@ void Formats::add(string const & name)
 }
 
 
+// FIXME: horrednously mis-named, especially given the other ::add
+// function
 void Formats::add(string const & name, string const & extension,
                  string const & prettyname, string const & shortcut)
 {
@@ -623,6 +621,14 @@ bool Converters::convert(Buffer const * buffer,
                                  subst(conv.result_file,
                                        token_base, OnlyFilename(from_base)));
 
+               // if input and output files are equal, we use a
+               // temporary file as intermediary (JMarc)
+               string real_outfile;
+               if (outfile == infile) {
+                       real_outfile = infile;
+                       outfile = AddName(buffer->tmppath, "tmpfile.out");
+               }
+
                if (conv.latex) {
                        run_latex = true;
                        string command = subst(conv.command, token_from, "");
@@ -673,6 +679,16 @@ bool Converters::convert(Buffer const * buffer,
                        } else
                                res = one.startscript(type, command);
 
+                       if (!real_outfile.empty()) {
+                               if (!lyx::rename(outfile, real_outfile))
+                                       res = -1;
+                               else
+                                       lyxerr[Debug::FILES]
+                                               << "renaming file " << outfile
+                                               << " to " << real_outfile
+                                               << endl;
+                       }
+
                        if (!conv.parselog.empty()) {
                                string const logfile =  infile2 + ".log";
                                string const script = LibScriptSearch(conv.parselog);
@@ -814,7 +830,7 @@ bool Converters::scanLog(Buffer const * buffer, string const & command,
 
        BufferView * bv = buffer->getUser();
        if (bv) {
-               bv->owner()->prohibitInput();
+               bv->owner()->busy(true);
                // all error insets should have been removed by now
        }
 
@@ -829,7 +845,7 @@ bool Converters::scanLog(Buffer const * buffer, string const & command,
                        bv->repaint();
                        bv->fitCursor();
                }
-               bv->owner()->allowInput();
+               bv->owner()->busy(false);
        }
 
        if ((result & LaTeX::ERRORS)) {
@@ -872,7 +888,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
        BufferView * bv = buffer->getUser();
 
        if (bv) {
-               bv->owner()->prohibitInput();
+               bv->owner()->busy(true);
                bv->owner()->message(_("Running LaTeX..."));
                // all the autoinsets have already been removed
        }
@@ -919,7 +935,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
        }
 
        if (bv)
-               bv->owner()->allowInput();
+               bv->owner()->busy(false);
 
        int const ERROR_MASK =
                        LaTeX::NO_LOGFILE |