]> git.lyx.org Git - lyx.git/blob - src/Converter.cpp
fix bug #6584
[lyx.git] / src / Converter.cpp
1 /**
2  * \file Converter.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Dekel Tsur
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Converter.h"
14
15 #include "Buffer.h"
16 #include "buffer_funcs.h"
17 #include "BufferParams.h"
18 #include "ConverterCache.h"
19 #include "Encoding.h"
20 #include "ErrorList.h"
21 #include "Format.h"
22 #include "Language.h"
23 #include "LaTeX.h"
24 #include "Mover.h"
25
26 #include "frontends/alert.h"
27
28 #include "support/debug.h"
29 #include "support/FileNameList.h"
30 #include "support/filetools.h"
31 #include "support/gettext.h"
32 #include "support/lstrings.h"
33 #include "support/os.h"
34 #include "support/Package.h"
35 #include "support/Path.h"
36 #include "support/Systemcall.h"
37
38 using namespace std;
39 using namespace lyx::support;
40
41 namespace lyx {
42
43 namespace Alert = lyx::frontend::Alert;
44
45
46 namespace {
47
48 string const token_from("$$i");
49 string const token_base("$$b");
50 string const token_to("$$o");
51 string const token_path("$$p");
52 string const token_orig_path("$$r");
53 string const token_encoding("$$e");
54
55
56 string const add_options(string const & command, string const & options)
57 {
58         string head;
59         string const tail = split(command, head, ' ');
60         return head + ' ' + options + ' ' + tail;
61 }
62
63
64 string const dvipdfm_options(BufferParams const & bp)
65 {
66         string result;
67
68         if (bp.papersize != PAPER_CUSTOM) {
69                 string const paper_size = bp.paperSizeName(BufferParams::DVIPDFM);
70                 if (!paper_size.empty())
71                         result = "-p "+ paper_size;
72
73                 if (bp.orientation == ORIENTATION_LANDSCAPE)
74                         result += " -l";
75         }
76
77         return result;
78 }
79
80
81 class ConverterEqual {
82 public:
83         ConverterEqual(string const & from, string const & to)
84                 : from_(from), to_(to) {}
85         bool operator()(Converter const & c) const {
86                 return c.from == from_ && c.to == to_;
87         }
88 private:
89         string const from_;
90         string const to_;
91 };
92
93 } // namespace anon
94
95
96 Converter::Converter(string const & f, string const & t,
97                      string const & c, string const & l)
98         : from(f), to(t), command(c), flags(l),
99           From(0), To(0), latex(false), xml(false),
100           need_aux(false)
101 {}
102
103
104 void Converter::readFlags()
105 {
106         string flag_list(flags);
107         while (!flag_list.empty()) {
108                 string flag_name, flag_value;
109                 flag_list = split(flag_list, flag_value, ',');
110                 flag_value = split(flag_value, flag_name, '=');
111                 if (flag_name == "latex") {
112                         latex = true;
113                         latex_flavor = flag_value.empty() ?
114                                 "latex" : flag_value;
115                 } else if (flag_name == "xml")
116                         xml = true;
117                 else if (flag_name == "needaux")
118                         need_aux = true;
119                 else if (flag_name == "resultdir")
120                         result_dir = (flag_value.empty())
121                                 ? token_base : flag_value;
122                 else if (flag_name == "resultfile")
123                         result_file = flag_value;
124                 else if (flag_name == "parselog")
125                         parselog = flag_value;
126         }
127         if (!result_dir.empty() && result_file.empty())
128                 result_file = "index." + formats.extension(to);
129         //if (!contains(command, token_from))
130         //      latex = true;
131 }
132
133
134 bool operator<(Converter const & a, Converter const & b)
135 {
136         // use the compare_ascii_no_case instead of compare_no_case,
137         // because in turkish, 'i' is not the lowercase version of 'I',
138         // and thus turkish locale breaks parsing of tags.
139         int const i = compare_ascii_no_case(a.From->prettyname(),
140                                             b.From->prettyname());
141         if (i == 0)
142                 return compare_ascii_no_case(a.To->prettyname(),
143                                              b.To->prettyname()) < 0;
144         else
145                 return i < 0;
146 }
147
148
149 Converter const * Converters::getConverter(string const & from,
150                                             string const & to) const
151 {
152         ConverterList::const_iterator const cit =
153                 find_if(converterlist_.begin(), converterlist_.end(),
154                         ConverterEqual(from, to));
155         if (cit != converterlist_.end())
156                 return &(*cit);
157         else
158                 return 0;
159 }
160
161
162 int Converters::getNumber(string const & from, string const & to) const
163 {
164         ConverterList::const_iterator const cit =
165                 find_if(converterlist_.begin(), converterlist_.end(),
166                         ConverterEqual(from, to));
167         if (cit != converterlist_.end())
168                 return distance(converterlist_.begin(), cit);
169         else
170                 return -1;
171 }
172
173
174 void Converters::add(string const & from, string const & to,
175                      string const & command, string const & flags)
176 {
177         formats.add(from);
178         formats.add(to);
179         ConverterList::iterator it = find_if(converterlist_.begin(),
180                                              converterlist_.end(),
181                                              ConverterEqual(from , to));
182
183         Converter converter(from, to, command, flags);
184         if (it != converterlist_.end() && !flags.empty() && flags[0] == '*') {
185                 converter = *it;
186                 converter.command = command;
187                 converter.flags = flags;
188         }
189         converter.readFlags();
190
191         // If we have both latex & pdflatex, we set latex_command to latex.
192         // The latex_command is used to update the .aux file when running
193         // a converter that uses it.
194         if (converter.latex
195             && (latex_command_.empty() || converter.latex_flavor == "latex"))
196                 latex_command_ = subst(command, token_from, "");
197
198         if (it == converterlist_.end()) {
199                 converterlist_.push_back(converter);
200         } else {
201                 converter.From = it->From;
202                 converter.To = it->To;
203                 *it = converter;
204         }
205 }
206
207
208 void Converters::erase(string const & from, string const & to)
209 {
210         ConverterList::iterator const it =
211                 find_if(converterlist_.begin(),
212                         converterlist_.end(),
213                         ConverterEqual(from, to));
214         if (it != converterlist_.end())
215                 converterlist_.erase(it);
216 }
217
218
219 // This method updates the pointers From and To in all the converters.
220 // The code is not very efficient, but it doesn't matter as the number
221 // of formats and converters is small.
222 // Furthermore, this method is called only on startup, or after
223 // adding/deleting a format in FormPreferences (the latter calls can be
224 // eliminated if the formats in the Formats class are stored using a map or
225 // a list (instead of a vector), but this will cause other problems).
226 void Converters::update(Formats const & formats)
227 {
228         ConverterList::iterator it = converterlist_.begin();
229         ConverterList::iterator end = converterlist_.end();
230         for (; it != end; ++it) {
231                 it->From = formats.getFormat(it->from);
232                 it->To = formats.getFormat(it->to);
233         }
234 }
235
236
237 // This method updates the pointers From and To in the last converter.
238 // It is called when adding a new converter in FormPreferences
239 void Converters::updateLast(Formats const & formats)
240 {
241         if (converterlist_.begin() != converterlist_.end()) {
242                 ConverterList::iterator it = converterlist_.end() - 1;
243                 it->From = formats.getFormat(it->from);
244                 it->To = formats.getFormat(it->to);
245         }
246 }
247
248
249 void Converters::sort()
250 {
251         std::sort(converterlist_.begin(), converterlist_.end());
252 }
253
254
255 OutputParams::FLAVOR Converters::getFlavor(Graph::EdgePath const & path)
256 {
257         for (Graph::EdgePath::const_iterator cit = path.begin();
258              cit != path.end(); ++cit) {
259                 Converter const & conv = converterlist_[*cit];
260                 if (conv.latex)
261                         if (conv.latex_flavor == "xelatex")
262                                 return OutputParams::XETEX;
263                         if (conv.latex_flavor == "lualatex")
264                                 return OutputParams::LUATEX;
265                         if (conv.latex_flavor == "pdflatex")
266                                 return OutputParams::PDFLATEX;
267                 if (conv.xml)
268                         return OutputParams::XML;
269         }
270         return OutputParams::LATEX;
271 }
272
273
274 bool Converters::convert(Buffer const * buffer,
275                          FileName const & from_file, FileName const & to_file,
276                          FileName const & orig_from,
277                          string const & from_format, string const & to_format,
278                          ErrorList & errorList, int conversionflags)
279 {
280         if (from_format == to_format)
281                 return move(from_format, from_file, to_file, false);
282
283         if ((conversionflags & try_cache) &&
284             ConverterCache::get().inCache(orig_from, to_format))
285                 return ConverterCache::get().copy(orig_from, to_format, to_file);
286
287         Graph::EdgePath edgepath = getPath(from_format, to_format);
288         if (edgepath.empty()) {
289                 if (conversionflags & try_default) {
290                         // if no special converter defined, then we take the
291                         // default one from ImageMagic.
292                         string const from_ext = from_format.empty() ?
293                                 getExtension(from_file.absFileName()) :
294                                 formats.extension(from_format);
295                         string const to_ext = formats.extension(to_format);
296                         string const command =
297                                 os::python() + ' ' +
298                                 quoteName(libFileSearch("scripts", "convertDefault.py").toFilesystemEncoding()) +
299                                 ' ' +
300                                 quoteName(from_ext + ':' + from_file.toFilesystemEncoding()) +
301                                 ' ' +
302                                 quoteName(to_ext + ':' + to_file.toFilesystemEncoding());
303                         LYXERR(Debug::FILES, "No converter defined! "
304                                    "I use convertDefault.py:\n\t" << command);
305                         Systemcall one;
306                         one.startscript(Systemcall::Wait, command);
307                         if (to_file.isReadableFile()) {
308                                 if (conversionflags & try_cache)
309                                         ConverterCache::get().add(orig_from,
310                                                         to_format, to_file);
311                                 return true;
312                         }
313                 }
314
315                 // only warn once per session and per file type
316                 static std::map<string, string> warned;
317                 if (warned.find(from_format) != warned.end() && warned.find(from_format)->second == to_format) {
318                         return false;
319                 }
320                 warned.insert(make_pair(from_format, to_format));
321
322                 Alert::error(_("Cannot convert file"),
323                              bformat(_("No information for converting %1$s "
324                                                     "format files to %2$s.\n"
325                                                     "Define a converter in the preferences."),
326                                                         from_ascii(from_format), from_ascii(to_format)));
327                 return false;
328         }
329
330         // buffer is only invalid for importing, and then runparams is not
331         // used anyway.
332         OutputParams runparams(buffer ? &buffer->params().encoding() : 0);
333         runparams.flavor = getFlavor(edgepath);
334
335         if (buffer) {
336                 runparams.use_japanese = buffer->bufferFormat() == "platex";
337                 runparams.use_indices = buffer->params().use_indices;
338                 runparams.bibtex_command = (buffer->params().bibtex_command == "default") ?
339                         string() : buffer->params().bibtex_command;
340                 runparams.index_command = (buffer->params().index_command == "default") ?
341                         string() : buffer->params().index_command;
342         }
343
344         // Some converters (e.g. lilypond) can only output files to the
345         // current directory, so we need to change the current directory.
346         // This has the added benefit that all other files that may be
347         // generated by the converter are deleted when LyX closes and do not
348         // clutter the real working directory.
349         string const path(onlyPath(from_file.absFileName()));
350         // Prevent the compiler from optimizing away p
351         FileName pp(path);
352         PathChanger p(pp);
353
354         // empty the error list before any new conversion takes place.
355         errorList.clear();
356
357         bool run_latex = false;
358         string from_base = changeExtension(from_file.absFileName(), "");
359         string to_base = changeExtension(to_file.absFileName(), "");
360         FileName infile;
361         FileName outfile = from_file;
362         for (Graph::EdgePath::const_iterator cit = edgepath.begin();
363              cit != edgepath.end(); ++cit) {
364                 Converter const & conv = converterlist_[*cit];
365                 bool dummy = conv.To->dummy() && conv.to != "program";
366                 if (!dummy) {
367                         LYXERR(Debug::FILES, "Converting from  "
368                                << conv.from << " to " << conv.to);
369                 }
370                 infile = outfile;
371                 outfile = FileName(conv.result_dir.empty()
372                         ? changeExtension(from_file.absFileName(), conv.To->extension())
373                         : addName(subst(conv.result_dir,
374                                         token_base, from_base),
375                                   subst(conv.result_file,
376                                         token_base, onlyFileName(from_base))));
377
378                 // if input and output files are equal, we use a
379                 // temporary file as intermediary (JMarc)
380                 FileName real_outfile;
381                 if (outfile == infile) {
382                         real_outfile = infile;
383                         // when importing, a buffer does not necessarily exist
384                         if (buffer)
385                                 outfile = FileName(addName(buffer->temppath(), "tmpfile.out"));
386                         else
387                                 outfile = FileName(addName(package().temp_dir().absFileName(),
388                                                    "tmpfile.out"));
389                 }
390
391                 if (conv.latex) {
392                         run_latex = true;
393                         string const command = subst(conv.command, token_from, "");
394                         LYXERR(Debug::FILES, "Running " << command);
395                         if (!runLaTeX(*buffer, command, runparams, errorList))
396                                 return false;
397                 } else {
398                         if (conv.need_aux && !run_latex
399                             && !latex_command_.empty()) {
400                                 LYXERR(Debug::FILES, "Running " << latex_command_
401                                         << " to update aux file");
402                                 runLaTeX(*buffer, latex_command_, runparams, errorList);
403                         }
404
405                         // FIXME UNICODE
406                         string const infile2 =
407                                 to_utf8(makeRelPath(from_utf8(infile.absFileName()), from_utf8(path)));
408                         string const outfile2 =
409                                 to_utf8(makeRelPath(from_utf8(outfile.absFileName()), from_utf8(path)));
410
411                         string command = conv.command;
412                         command = subst(command, token_from, quoteName(infile2));
413                         command = subst(command, token_base, quoteName(from_base));
414                         command = subst(command, token_to, quoteName(outfile2));
415                         command = subst(command, token_path, quoteName(infile.onlyPath().absFileName()));
416                         command = subst(command, token_orig_path, quoteName(orig_from.onlyPath().absFileName()));
417                         command = subst(command, token_encoding, buffer ? buffer->params().encoding().iconvName() : string());
418                         command = libScriptSearch(command);
419
420                         if (!conv.parselog.empty())
421                                 command += " 2> " + quoteName(infile2 + ".out");
422
423                         if (conv.from == "dvi" && conv.to == "ps")
424                                 command = add_options(command,
425                                                       buffer->params().dvips_options());
426                         else if (conv.from == "dvi" && prefixIs(conv.to, "pdf"))
427                                 command = add_options(command,
428                                                       dvipdfm_options(buffer->params()));
429
430                         LYXERR(Debug::FILES, "Calling " << command);
431                         if (buffer)
432                                 buffer->message(_("Executing command: ")
433                                 + from_utf8(command));
434
435                         Systemcall one;
436                         int res;
437                         if (dummy) {
438                                 res = one.startscript(Systemcall::DontWait,
439                                         to_filesystem8bit(from_utf8(command)));
440                                 // We're not waiting for the result, so we can't do anything
441                                 // else here.
442                         } else {
443                                 res = one.startscript(Systemcall::Wait,
444                                                 to_filesystem8bit(from_utf8(command)));
445                                 if (!real_outfile.empty()) {
446                                         Mover const & mover = getMover(conv.to);
447                                         if (!mover.rename(outfile, real_outfile))
448                                                 res = -1;
449                                         else
450                                                 LYXERR(Debug::FILES, "renaming file " << outfile
451                                                         << " to " << real_outfile);
452                                         // Finally, don't forget to tell any future
453                                         // converters to use the renamed file...
454                                         outfile = real_outfile;
455                                 }
456   
457                                 if (!conv.parselog.empty()) {
458                                         string const logfile =  infile2 + ".log";
459                                         string const script = libScriptSearch(conv.parselog);
460                                         string const command2 = script +
461                                                 " < " + quoteName(infile2 + ".out") +
462                                                 " > " + quoteName(logfile);
463                                         one.startscript(Systemcall::Wait,
464                                                 to_filesystem8bit(from_utf8(command2)));
465                                         if (!scanLog(*buffer, command, makeAbsPath(logfile, path), errorList))
466                                                 return false;
467                                 }
468                         }
469
470                         if (res) {
471                                 if (conv.to == "program") {
472                                         Alert::error(_("Build errors"),
473                                                 _("There were errors during the build process."));
474                                 } else {
475 // FIXME: this should go out of here. For example, here we cannot say if
476 // it is a document (.lyx) or something else. Same goes for elsewhere.
477                                         Alert::error(_("Cannot convert file"),
478                                                 bformat(_("An error occurred while running:\n%1$s"),
479                                                 wrapParas(from_utf8(command))));
480                                 }
481                                 return false;
482                         }
483                 }
484         }
485
486         Converter const & conv = converterlist_[edgepath.back()];
487         if (conv.To->dummy())
488                 return true;
489
490         if (!conv.result_dir.empty()) {
491                 // The converter has put the file(s) in a directory.
492                 // In this case we ignore the given to_file.
493                 if (from_base != to_base) {
494                         string const from = subst(conv.result_dir,
495                                             token_base, from_base);
496                         string const to = subst(conv.result_dir,
497                                           token_base, to_base);
498                         Mover const & mover = getMover(conv.from);
499                         if (!mover.rename(FileName(from), FileName(to))) {
500                                 Alert::error(_("Cannot convert file"),
501                                         bformat(_("Could not move a temporary directory from %1$s to %2$s."),
502                                                 from_utf8(from), from_utf8(to)));
503                                 return false;
504                         }
505                 }
506                 return true;
507         } else {
508                 if (conversionflags & try_cache)
509                         ConverterCache::get().add(orig_from, to_format, outfile);
510                 return move(conv.to, outfile, to_file, conv.latex);
511         }
512 }
513
514
515 bool Converters::move(string const & fmt,
516                       FileName const & from, FileName const & to, bool copy)
517 {
518         if (from == to)
519                 return true;
520
521         bool no_errors = true;
522         string const path = onlyPath(from.absFileName());
523         string const base = onlyFileName(removeExtension(from.absFileName()));
524         string const to_base = removeExtension(to.absFileName());
525         string const to_extension = getExtension(to.absFileName());
526
527         support::FileNameList const files = FileName(path).dirList(getExtension(from.absFileName()));
528         for (support::FileNameList::const_iterator it = files.begin();
529              it != files.end(); ++it) {
530                 string const from2 = it->absFileName();
531                 string const file2 = onlyFileName(from2);
532                 if (prefixIs(file2, base)) {
533                         string const to2 = changeExtension(
534                                 to_base + file2.substr(base.length()),
535                                 to_extension);
536                         LYXERR(Debug::FILES, "moving " << from2 << " to " << to2);
537
538                         Mover const & mover = getMover(fmt);
539                         bool const moved = copy
540                                 ? mover.copy(*it, FileName(to2))
541                                 : mover.rename(*it, FileName(to2));
542                         if (!moved && no_errors) {
543                                 Alert::error(_("Cannot convert file"),
544                                         bformat(copy ?
545                                                 _("Could not copy a temporary file from %1$s to %2$s.") :
546                                                 _("Could not move a temporary file from %1$s to %2$s."),
547                                                 from_utf8(from2), from_utf8(to2)));
548                                 no_errors = false;
549                         }
550                 }
551         }
552         return no_errors;
553 }
554
555
556 bool Converters::formatIsUsed(string const & format)
557 {
558         ConverterList::const_iterator cit = converterlist_.begin();
559         ConverterList::const_iterator end = converterlist_.end();
560         for (; cit != end; ++cit) {
561                 if (cit->from == format || cit->to == format)
562                         return true;
563         }
564         return false;
565 }
566
567
568 bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
569                          FileName const & filename, ErrorList & errorList)
570 {
571         OutputParams runparams(0);
572         runparams.flavor = OutputParams::LATEX;
573         LaTeX latex("", runparams, filename);
574         TeXErrors terr;
575         int const result = latex.scanLogFile(terr);
576
577         if (result & LaTeX::ERRORS)
578                 buffer.bufferErrors(terr, errorList);
579
580         return true;
581 }
582
583
584 namespace {
585
586 class ShowMessage
587         : public boost::signals::trackable {
588 public:
589         ShowMessage(Buffer const & b) : buffer_(b) {}
590         void operator()(docstring const & msg) const { buffer_.message(msg); }
591 private:
592         Buffer const & buffer_;
593 };
594
595 }
596
597
598 bool Converters::runLaTeX(Buffer const & buffer, string const & command,
599                           OutputParams const & runparams, ErrorList & errorList)
600 {
601         buffer.setBusy(true);
602         buffer.message(_("Running LaTeX..."));
603
604         runparams.document_language = buffer.params().language->babel();
605
606         // do the LaTeX run(s)
607         string const name = buffer.latexName();
608         LaTeX latex(command, runparams, FileName(makeAbsPath(name)));
609         TeXErrors terr;
610         ShowMessage show(buffer);
611         latex.message.connect(show);
612         int const result = latex.run(terr);
613
614         if (result & LaTeX::ERRORS)
615                 buffer.bufferErrors(terr, errorList);
616
617         // check return value from latex.run().
618         if ((result & LaTeX::NO_LOGFILE) && !buffer.isClone()) {
619                 docstring const str =
620                         bformat(_("LaTeX did not run successfully. "
621                                                "Additionally, LyX could not locate "
622                                                "the LaTeX log %1$s."), from_utf8(name));
623                 Alert::error(_("LaTeX failed"), str);
624         } else if ((result & LaTeX::NO_OUTPUT) && !buffer.isClone()) {
625                 Alert::warning(_("Output is empty"),
626                                _("An empty output file was generated."));
627         }
628
629
630         buffer.setBusy(false);
631
632         int const ERROR_MASK =
633                         LaTeX::NO_LOGFILE |
634                         LaTeX::ERRORS |
635                         LaTeX::NO_OUTPUT;
636
637         return (result & ERROR_MASK) == 0;
638
639 }
640
641
642
643 void Converters::buildGraph()
644 {
645         // clear graph's data structures
646         G_.init(formats.size());
647         // each of the converters knows how to convert one format to another
648         // so, for each of them, we create an arrow on the graph, going from 
649         // the one to the other
650         ConverterList::iterator it = converterlist_.begin();
651         ConverterList::iterator const end = converterlist_.end();
652         for (; it != end ; ++it) {
653                 int const from = formats.getNumber(it->from);
654                 int const to   = formats.getNumber(it->to);
655                 G_.addEdge(from, to);
656         }
657 }
658
659
660 vector<Format const *> const
661 Converters::intToFormat(vector<int> const & input)
662 {
663         vector<Format const *> result(input.size());
664
665         vector<int>::const_iterator it = input.begin();
666         vector<int>::const_iterator const end = input.end();
667         vector<Format const *>::iterator rit = result.begin();
668         for ( ; it != end; ++it, ++rit) {
669                 *rit = &formats.get(*it);
670         }
671         return result;
672 }
673
674
675 vector<Format const *> const
676 Converters::getReachableTo(string const & target, bool const clear_visited)
677 {
678         vector<int> const & reachablesto =
679                 G_.getReachableTo(formats.getNumber(target), clear_visited);
680
681         return intToFormat(reachablesto);
682 }
683
684
685 vector<Format const *> const
686 Converters::getReachable(string const & from, bool const only_viewable,
687                          bool const clear_visited)
688 {
689         vector<int> const & reachables =
690                 G_.getReachable(formats.getNumber(from),
691                                 only_viewable,
692                                 clear_visited);
693
694         return intToFormat(reachables);
695 }
696
697
698 bool Converters::isReachable(string const & from, string const & to)
699 {
700         return G_.isReachable(formats.getNumber(from),
701                               formats.getNumber(to));
702 }
703
704
705 Graph::EdgePath Converters::getPath(string const & from, string const & to)
706 {
707         return G_.getPath(formats.getNumber(from),
708                           formats.getNumber(to));
709 }
710
711
712 vector<Format const *> Converters::importableFormats()
713 {
714         vector<string> l = loaders();
715         vector<Format const *> result = getReachableTo(l[0], true);
716         for (vector<string>::const_iterator it = l.begin() + 1;
717              it != l.end(); ++it) {
718                 vector<Format const *> r = getReachableTo(*it, false);
719                 result.insert(result.end(), r.begin(), r.end());
720         }
721         return result;
722 }
723
724
725 vector<Format const *> Converters::exportableFormats(bool only_viewable)
726 {
727         vector<string> s = savers();
728         vector<Format const *> result = getReachable(s[0], only_viewable, true);
729         for (vector<string>::const_iterator it = s.begin() + 1;
730              it != s.end(); ++it) {
731                 vector<Format const *> r =
732                         getReachable(*it, only_viewable, false);
733                 result.insert(result.end(), r.begin(), r.end());
734         }
735         return result;
736 }
737
738
739 vector<string> Converters::loaders() const
740 {
741         vector<string> v;
742         v.push_back("lyx");
743         v.push_back("text");
744         v.push_back("textparagraph");
745         return v;
746 }
747
748
749 vector<string> Converters::savers() const
750 {
751         vector<string> v;
752         v.push_back("docbook");
753         v.push_back("latex");
754         v.push_back("literate");
755         v.push_back("luatex");
756         v.push_back("lyx");
757         v.push_back("xhtml");
758         v.push_back("pdflatex");
759         v.push_back("platex");
760         v.push_back("text");
761         v.push_back("xetex");
762         return v;
763 }
764
765
766 } // namespace lyx