]> git.lyx.org Git - lyx.git/blobdiff - src/converter.C
Make it compile when USE_BOOST_FORMAT is unset
[lyx.git] / src / converter.C
index f91c85f6077e552e167a7e28cea6c181ac3fc4f3..7b37f0a68d7450f1e85384c6f492ae156f31d7cd 100644 (file)
 #pragma implementation
 #endif
 
-#include <cctype>
-
 #include "converter.h"
 #include "lyxrc.h"
 #include "buffer.h"
 #include "bufferview_funcs.h"
 #include "LaTeX.h"
-#include "frontends/LyXView.h"
 #include "lyx_cb.h" // ShowMessage()
 #include "gettext.h"
 #include "BufferView.h"
 #include "debug.h"
 
 #include "frontends/Alert.h"
+#include "frontends/LyXView.h"
 
 #include "support/filetools.h"
 #include "support/lyxfunctional.h"
 #include "support/path.h"
 #include "support/systemcall.h"
 
+#include "BoostFormat.h"
+
+#include <cctype>
+
 #ifndef CXX_GLOBAL_CSTD
 using std::isdigit;
 #endif
@@ -51,6 +53,7 @@ namespace {
 string const token_from("$$i");
 string const token_base("$$b");
 string const token_to("$$o");
+string const token_path("$$p");
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -174,9 +177,15 @@ bool Formats::view(Buffer const * buffer, string const & filename,
            format->isChildFormat())
                format = getFormat(format->parentFormat());
        if (!format || format->viewer().empty()) {
+#if USE_BOOST_FORMAT
                Alert::alert(_("Cannot view file"),
-                          _("No information for viewing ")
-                          + prettyName(format_name));
+                            boost::io::str(boost::format(_("No information for viewing %1$s"))
+                          % prettyName(format_name)));
+#else
+               Alert::alert(_("Cannot view file"),
+                            _("No information for viewing ")
+                            + prettyName(format_name));
+#endif
                           return false;
        }
 
@@ -194,7 +203,12 @@ bool Formats::view(Buffer const * buffer, string const & filename,
                        command += 'r';
        }
 
-       command += " " + QuoteName(OnlyFilename((filename)));
+       if (!contains(command, token_from))
+               command += " " + token_from;
+
+       command = subst(command, token_from,
+                       QuoteName(OnlyFilename(filename)));
+       command = subst(command, token_path, QuoteName(OnlyPath(filename)));
 
        lyxerr[Debug::FILES] << "Executing command: " << command << endl;
        ShowMessage(buffer, _("Executing command:"), command);
@@ -264,10 +278,13 @@ void Converter::readFlags()
 
 bool operator<(Converter const & a, Converter const & b)
 {
-       int const i = compare_no_case(a.From->prettyname(),
-                                     b.From->prettyname());
+       // use the compare_ascii_no_case instead of compare_no_case,
+       // because in turkish, 'i' is not the lowercase version of 'I',
+       // and thus turkish locale breaks parsing of tags.
+       int const i = compare_ascii_no_case(a.From->prettyname(),
+                                           b.From->prettyname());
        if (i == 0)
-               return compare_no_case(a.To->prettyname(), b.To->prettyname())
+               return compare_ascii_no_case(a.To->prettyname(), b.To->prettyname())
                        < 0;
        else
                return i < 0;
@@ -630,6 +647,7 @@ bool Converters::convert(Buffer const * buffer,
                        command = subst(command, token_from, QuoteName(infile2));
                        command = subst(command, token_base, QuoteName(from_base));
                        command = subst(command, token_to, QuoteName(outfile2));
+                       command = LibScriptSearch(command);
 
                        if (!conv.parselog.empty())
                                command += " 2> " + QuoteName(infile2 + ".out");
@@ -672,7 +690,7 @@ bool Converters::convert(Buffer const * buffer,
                                                   _("You should try to fix them."));
                                else
                                        Alert::alert(_("Cannot convert file"),
-                                                  "Error while executing",
+                                                  _("Error while executing"),
                                                   command.substr(0, 50));
                                return false;
                        }
@@ -694,8 +712,13 @@ bool Converters::convert(Buffer const * buffer,
                        string to = subst(conv.result_dir,
                                          token_base, to_base);
                        if (!lyx::rename(from, to)) {
+#if USE_BOOST_FORMAT
+                               Alert::alert(_("Error while trying to move directory:"),
+                                          from, boost::io::str(boost::format(_("to %1$s")) % to));
+#else
                                Alert::alert(_("Error while trying to move directory:"),
-                                          from, ("to ") + to);
+                                          from, _("to ") + to);
+#endif
                                return false;
                        }
                }
@@ -704,6 +727,7 @@ bool Converters::convert(Buffer const * buffer,
                return move(outfile, to_file, conv.latex);
 }
 
+
 // If from = /path/file.ext and to = /path2/file2.ext2 then this method
 // moves each /path/file*.ext file to /path2/file2*.ext2'
 bool Converters::move(string const & from, string const & to, bool copy)
@@ -730,8 +754,13 @@ bool Converters::move(string const & from, string const & to, bool copy)
                                ? lyx::copy(from2, to2)
                                : lyx::rename(from2, to2);
                        if (!moved && no_errors) {
+#if USE_BOOST_FORMAT
+                               Alert::alert(_("Error while trying to move file:"),
+                                          from2, boost::io::str(boost::format(_("to %1$s")) % to2));
+#else
                                Alert::alert(_("Error while trying to move file:"),
                                           from2, _("to ") + to2);
+#endif
                                no_errors = false;
                        }
                }
@@ -817,8 +846,13 @@ bool Converters::scanLog(Buffer const * buffer, string const & command,
                }
                string head;
                split(command, head, ' ');
+#if USE_BOOST_FORMAT
+               Alert::alert(boost::io::str(boost::format(_("There were errors during running of %1$s")) % head),
+                          s, t);
+#else
                Alert::alert(_("There were errors during running of ") + head,
                           s, t);
+#endif
                return false;
        } else if (result & LaTeX::NO_OUTPUT) {
                string const s = _("The operation resulted in");
@@ -848,7 +882,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
        LaTeX latex(command, name, buffer->filePath());
        TeXErrors terr;
        int result = latex.run(terr,
-                              bv ? bv->owner()->getLyXFunc() : 0);
+                              bv ? &bv->owner()->getLyXFunc() : 0);
 
        if (bv) {
                if ((result & LaTeX::ERRORS)) {