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