]> git.lyx.org Git - lyx.git/blobdiff - src/Converter.cpp
* gcc does not like missing characters in keywords
[lyx.git] / src / Converter.cpp
index e704cf12d41a1a1003b1b34883b1fd03dfdfaacf..b168cd1a240c4a715a9b647952a86f4a86ccabd4 100644 (file)
 #include "support/Path.h"
 #include "support/Systemcall.h"
 
+using std::endl;
+using std::find_if;
+using std::string;
+using std::vector;
+using std::distance;
+
 
 namespace lyx {
 
@@ -44,7 +50,6 @@ using support::contains;
 using support::dirList;
 using support::FileName;
 using support::getExtension;
-using support::isFileReadable;
 using support::libFileSearch;
 using support::libScriptSearch;
 using support::makeAbsPath;
@@ -59,12 +64,6 @@ using support::split;
 using support::subst;
 using support::Systemcall;
 
-using std::endl;
-using std::find_if;
-using std::string;
-using std::vector;
-using std::distance;
-
 namespace Alert = lyx::frontend::Alert;
 
 
@@ -323,7 +322,7 @@ bool Converters::convert(Buffer const * buffer,
                                << command << endl;
                        Systemcall one;
                        one.startscript(Systemcall::Wait, command);
-                       if (isFileReadable(to_file)) {
+                       if (to_file.isFileReadable()) {
                                if (conversionflags & try_cache)
                                        ConverterCache::get().add(orig_from,
                                                        to_format, to_file);
@@ -365,9 +364,10 @@ bool Converters::convert(Buffer const * buffer,
             cit != edgepath.end(); ++cit) {
                Converter const & conv = converterlist_[*cit];
                bool dummy = conv.To->dummy() && conv.to != "program";
-               if (!dummy)
+               if (!dummy) {
                        LYXERR(Debug::FILES) << "Converting from  "
                               << conv.from << " to " << conv.to << endl;
+               }
                infile = outfile;
                outfile = FileName(conv.result_dir.empty()
                        ? changeExtension(from_file.absFilename(), conv.To->extension())
@@ -578,7 +578,7 @@ bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
        int const result = latex.scanLogFile(terr);
 
        if (result & LaTeX::ERRORS)
-               bufferErrors(buffer, terr, errorList);
+               buffer.bufferErrors(terr, errorList);
 
        return true;
 }
@@ -586,13 +586,11 @@ bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
 
 namespace {
 
-class showMessage : public std::unary_function<docstring, void>, public boost::signals::trackable {
+class ShowMessage
+       : public boost::signals::trackable {
 public:
-       showMessage(Buffer const & b) : buffer_(b) {};
-       void operator()(docstring const & m) const
-       {
-               buffer_.message(m);
-       }
+       ShowMessage(Buffer const & b) : buffer_(b) {}
+       void operator()(docstring const & msg) const { buffer_.message(msg); }
 private:
        Buffer const & buffer_;
 };
@@ -603,21 +601,21 @@ private:
 bool Converters::runLaTeX(Buffer const & buffer, string const & command,
                          OutputParams const & runparams, ErrorList & errorList)
 {
-       buffer.busy(true);
+       buffer.setBusy(true);
        buffer.message(_("Running LaTeX..."));
 
        runparams.document_language = buffer.params().language->babel();
 
        // do the LaTeX run(s)
-       string const name = buffer.getLatexName();
+       string const name = buffer.latexName();
        LaTeX latex(command, runparams, FileName(makeAbsPath(name)));
        TeXErrors terr;
-       showMessage show(buffer);
+       ShowMessage show(buffer);
        latex.message.connect(show);
        int const result = latex.run(terr);
 
        if (result & LaTeX::ERRORS)
-               bufferErrors(buffer, terr, errorList);
+               buffer.bufferErrors(terr, errorList);
 
        // check return value from latex.run().
        if ((result & LaTeX::NO_LOGFILE)) {
@@ -632,7 +630,7 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
        }
 
 
-       buffer.busy(false);
+       buffer.setBusy(false);
 
        int const ERROR_MASK =
                        LaTeX::NO_LOGFILE |
@@ -703,11 +701,34 @@ bool Converters::isReachable(string const & from, string const & to)
 }
 
 
-Graph::EdgePath const
-Converters::getPath(string const & from, string const & to)
+Graph::EdgePath Converters::getPath(string const & from, string const & to)
 {
        return G_.getPath(formats.getNumber(from),
                          formats.getNumber(to));
 }
 
+
+vector<Format const *> Converters::importableFormats()
+{
+       vector<string> l = loaders();
+       vector<Format const *> result = getReachableTo(l[0], true);
+       for (vector<string>::const_iterator it = l.begin() + 1;
+            it != l.end(); ++it) {
+               vector<Format const *> r = getReachableTo(*it, false);
+               result.insert(result.end(), r.begin(), r.end());
+       }
+       return result;
+}
+
+
+vector<string> Converters::loaders() const
+{
+       vector<string> v;
+       v.push_back("lyx");
+       v.push_back("text");
+       v.push_back("textparagraph");
+       return v;
+}
+
+
 } // namespace lyx