]> git.lyx.org Git - lyx.git/blob - src/Format.cpp
8e31a1e96bded7db0958f57b71a275a3b37a3f97
[lyx.git] / src / Format.cpp
1 /**
2  * \file Format.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 "Format.h"
14 #include "Buffer.h"
15 #include "BufferParams.h"
16 #include "LyXRC.h"
17 #include "ServerSocket.h"
18
19 #include "frontends/alert.h" //to be removed?
20
21 #include "support/debug.h"
22 #include "support/filetools.h"
23 #include "support/gettext.h"
24 #include "support/lstrings.h"
25 #include "support/os.h"
26 #include "support/PathChanger.h"
27 #include "support/Systemcall.h"
28 #include "support/textutils.h"
29 #include "support/Translator.h"
30
31 #include <algorithm>
32 #include <map>
33 #include <ctime>
34
35 // FIXME: Q_WS_MACX is not available, it's in Qt
36 #ifdef USE_MACOSX_PACKAGING
37 #include "support/linkback/LinkBackProxy.h"
38 #endif
39
40 #ifdef HAVE_MAGIC_H
41 #include <magic.h>
42 #endif
43
44 using namespace std;
45 using namespace lyx::support;
46
47 namespace lyx {
48
49 namespace Alert = frontend::Alert;
50 namespace os = support::os;
51
52 namespace {
53
54 string const token_from_format("$$i");
55 string const token_path_format("$$p");
56 string const token_socket_format("$$a");
57
58
59 class FormatNamesEqual : public unary_function<Format, bool> {
60 public:
61         FormatNamesEqual(string const & name)
62                 : name_(name)
63         {}
64         bool operator()(Format const & f) const
65         {
66                 return f.name() == name_;
67         }
68 private:
69         string name_;
70 };
71
72
73 class FormatExtensionsEqual : public unary_function<Format, bool> {
74 public:
75         FormatExtensionsEqual(string const & extension)
76                 : extension_(extension)
77         {}
78         bool operator()(Format const & f) const
79         {
80                 return f.hasExtension(extension_);
81         }
82 private:
83         string extension_;
84 };
85
86
87 class FormatMimeEqual : public unary_function<Format, bool> {
88 public:
89         FormatMimeEqual(string const & mime)
90                 : mime_(mime)
91         {}
92         bool operator()(Format const & f) const
93         {
94                 // The test for empty mime strings is needed since we allow
95                 // formats with empty mime types.
96                 return f.mime() == mime_ && !mime_.empty();
97         }
98 private:
99         string mime_;
100 };
101
102
103 class FormatPrettyNameEqual : public unary_function<Format, bool> {
104 public:
105         FormatPrettyNameEqual(string const & prettyname)
106                 : prettyname_(prettyname)
107         {}
108         bool operator()(Format const & f) const
109         {
110                 return f.prettyname() == prettyname_;
111         }
112 private:
113         string prettyname_;
114 };
115
116 } //namespace anon
117
118 bool Format::formatSorter(Format const * lhs, Format const * rhs)
119 {
120         return _(lhs->prettyname()) < _(rhs->prettyname());
121 }
122
123 bool operator<(Format const & a, Format const & b)
124 {
125         return _(a.prettyname()) < _(b.prettyname());
126 }
127
128
129 Format::Format(string const & n, string const & e, string const & p,
130                string const & s, string const & v, string const & ed,
131                string const & m, int flags)
132         : name_(n), prettyname_(p), shortcut_(s), viewer_(v),
133           editor_(ed), mime_(m), flags_(flags)
134 {
135         extension_list_ = getVectorFromString(e, ",");
136         LYXERR(Debug::GRAPHICS, "New Format: n=" << n << ", flags=" << flags);
137 }
138
139
140 bool Format::dummy() const
141 {
142         return extension().empty();
143 }
144
145
146 string const Format::extensions() const
147 {
148         return getStringFromVector(extension_list_, ", ");
149 }
150
151
152 bool Format::hasExtension(string const & e) const
153 {
154         return (find(extension_list_.begin(), extension_list_.end(), e)
155                 != extension_list_.end());
156 }
157
158
159 bool Format::isChildFormat() const
160 {
161         if (name_.empty())
162                 return false;
163         return isDigitASCII(name_[name_.length() - 1]);
164 }
165
166
167 string const Format::parentFormat() const
168 {
169         return name_.substr(0, name_.length() - 1);
170 }
171
172
173 void Format::setExtensions(string const & e)
174 {
175         extension_list_ = getVectorFromString(e, ",");
176 }
177
178
179 // This method should return a reference, and throw an exception
180 // if the format named name cannot be found (Lgb)
181 Format const * Formats::getFormat(string const & name) const
182 {
183         FormatList::const_iterator cit =
184                 find_if(formatlist.begin(), formatlist.end(),
185                         FormatNamesEqual(name));
186         if (cit != formatlist.end())
187                 return &(*cit);
188         else
189                 return 0;
190 }
191
192
193 namespace {
194
195 /** Guess the file format name (as in Format::name()) from contents.
196  *  Normally you don't want to use this directly, but rather
197  *  Formats::getFormatFromFile().
198  */
199 string guessFormatFromContents(FileName const & fn)
200 {
201         // the different filetypes and what they contain in one of the first lines
202         // (dots are any characters).           (Herbert 20020131)
203         // AGR  Grace...
204         // BMP  BM...
205         // EPS  %!PS-Adobe-3.0 EPSF...
206         // FIG  #FIG...
207         // FITS ...BITPIX...
208         // GIF  GIF...
209         // JPG  JFIF
210         // PDF  %PDF-...
211         // PNG  .PNG...
212         // PBM  P1... or P4     (B/W)
213         // PGM  P2... or P5     (Grayscale)
214         // PPM  P3... or P6     (color)
215         // PS   %!PS-Adobe-2.0 or 1.0,  no "EPSF"!
216         // SGI  \001\332...     (decimal 474)
217         // TGIF %TGIF...
218         // TIFF II... or MM...
219         // XBM  ..._bits[]...
220         // XPM  /* XPM */    sometimes missing (f.ex. tgif-export)
221         //      ...static char *...
222         // XWD  \000\000\000\151        (0x00006900) decimal 105
223         //
224         // GZIP \037\213        http://www.ietf.org/rfc/rfc1952.txt
225         // ZIP  PK...                   http://www.halyava.ru/document/ind_arch.htm
226         // Z    \037\235                UNIX compress
227
228         // paranoia check
229         if (fn.empty() || !fn.isReadableFile())
230                 return string();
231
232         ifstream ifs(fn.toFilesystemEncoding().c_str());
233         if (!ifs)
234                 // Couldn't open file...
235                 return string();
236
237         // gnuzip
238         static string const gzipStamp = "\037\213";
239
240         // PKZIP
241         static string const zipStamp = "PK";
242
243         // ZIP containers (koffice, openoffice.org etc).
244         static string const nonzipStamp = "\008\0\0\0mimetypeapplication/";
245
246         // compress
247         static string const compressStamp = "\037\235";
248
249         // Maximum strings to read
250         int const max_count = 50;
251         int count = 0;
252
253         string str;
254         string format;
255         bool firstLine = true;
256         while ((count++ < max_count) && format.empty()) {
257                 if (ifs.eof()) {
258                         LYXERR(Debug::GRAPHICS, "filetools(getFormatFromContents)\n"
259                                 << "\tFile type not recognised before EOF!");
260                         break;
261                 }
262
263                 getline(ifs, str);
264                 string const stamp = str.substr(0, 2);
265                 if (firstLine && str.size() >= 2) {
266                         // at first we check for a zipped file, because this
267                         // information is saved in the first bytes of the file!
268                         // also some graphic formats which save the information
269                         // in the first line, too.
270                         if (prefixIs(str, gzipStamp)) {
271                                 format =  "gzip";
272
273                         } else if (stamp == zipStamp &&
274                                    !contains(str, nonzipStamp)) {
275                                 format =  "zip";
276
277                         } else if (stamp == compressStamp) {
278                                 format =  "compress";
279
280                         // the graphics part
281                         } else if (stamp == "BM") {
282                                 format =  "bmp";
283
284                         } else if (stamp == "\001\332") {
285                                 format =  "sgi";
286
287                         // PBM family
288                         // Don't need to use str.at(0), str.at(1) because
289                         // we already know that str.size() >= 2
290                         } else if (str[0] == 'P') {
291                                 switch (str[1]) {
292                                 case '1':
293                                 case '4':
294                                         format =  "pbm";
295                                     break;
296                                 case '2':
297                                 case '5':
298                                         format =  "pgm";
299                                     break;
300                                 case '3':
301                                 case '6':
302                                         format =  "ppm";
303                                 }
304                                 break;
305
306                         } else if ((stamp == "II") || (stamp == "MM")) {
307                                 format =  "tiff";
308
309                         } else if (prefixIs(str,"%TGIF")) {
310                                 format =  "tgif";
311
312                         } else if (prefixIs(str,"#FIG")) {
313                                 format =  "fig";
314
315                         } else if (prefixIs(str,"GIF")) {
316                                 format =  "gif";
317
318                         } else if (str.size() > 3) {
319                                 int const c = ((str[0] << 24) & (str[1] << 16) &
320                                                (str[2] << 8)  & str[3]);
321                                 if (c == 105) {
322                                         format =  "xwd";
323                                 }
324                         }
325
326                         firstLine = false;
327                 }
328
329                 if (!format.empty())
330                     break;
331                 else if (contains(str,"EPSF"))
332                         // dummy, if we have wrong file description like
333                         // %!PS-Adobe-2.0EPSF"
334                         format = "eps";
335
336                 else if (contains(str, "Grace"))
337                         format = "agr";
338
339                 else if (contains(str, "JFIF"))
340                         format = "jpg";
341
342                 else if (contains(str, "%PDF"))
343                         // autodetect pdf format for graphics inclusion
344                         format = "pdf6";
345
346                 else if (contains(str, "PNG"))
347                         format = "png";
348
349                 else if (contains(str, "%!PS-Adobe")) {
350                         // eps or ps
351                         ifs >> str;
352                         if (contains(str,"EPSF"))
353                                 format = "eps";
354                         else
355                             format = "ps";
356                 }
357
358                 else if (contains(str, "_bits[]"))
359                         format = "xbm";
360
361                 else if (contains(str, "XPM") || contains(str, "static char *"))
362                         format = "xpm";
363
364                 else if (contains(str, "BITPIX"))
365                         format = "fits";
366         }
367
368         if (!format.empty()) {
369                 LYXERR(Debug::GRAPHICS, "Recognised Fileformat: " << format);
370                 return format;
371         }
372
373         LYXERR(Debug::GRAPHICS, "filetools(getFormatFromContents)\n"
374                 << "\tCouldn't find a known format!");
375         return string();
376 }
377
378 }
379
380
381 string Formats::getFormatFromFile(FileName const & filename) const
382 {
383         if (filename.empty())
384                 return string();
385
386 #ifdef HAVE_MAGIC_H
387         if (filename.exists()) {
388                 magic_t magic_cookie = magic_open(MAGIC_MIME);
389                 if (magic_cookie) {
390                         string format;
391                         if (magic_load(magic_cookie, NULL) != 0) {
392                                 LYXERR(Debug::GRAPHICS, "Formats::getFormatFromFile\n"
393                                         << "\tCouldn't load magic database - "
394                                         << magic_error(magic_cookie));
395                         } else {
396                                 string mime = magic_file(magic_cookie,
397                                         filename.toFilesystemEncoding().c_str());
398                                 mime = token(mime, ';', 0);
399                                 // we need our own ps/eps detection
400                                 if ((mime != "application/postscript") && (mime != "text/plain")) {
401                                         Formats::const_iterator cit =
402                                                 find_if(formatlist.begin(), formatlist.end(),
403                                                         FormatMimeEqual(mime));
404                                         if (cit != formats.end()) {
405                                                 LYXERR(Debug::GRAPHICS, "\tgot format from MIME type: "
406                                                         << mime << " -> " << cit->name());
407                                                 format = cit->name();
408                                         }
409                                 }
410                         }
411                         magic_close(magic_cookie);
412                         if (!format.empty())
413                                 return format;
414                 }
415         }
416 #endif
417
418         string const format = guessFormatFromContents(filename);
419         string const ext = getExtension(filename.absFileName());
420         if (isZippedFileFormat(format) && !ext.empty()) {
421                 string const & fmt_name = formats.getFormatFromExtension(ext);
422                 if (!fmt_name.empty()) {
423                         Format const * p_format = formats.getFormat(fmt_name);
424                         if (p_format && p_format->zippedNative())
425                                 return p_format->name();
426                 }
427         }
428         if (!format.empty())
429                 return format;
430
431         // try to find a format from the file extension.
432         return getFormatFromExtension(ext);
433 }
434
435
436 string Formats::getFormatFromExtension(string const & ext) const
437 {
438         if (!ext.empty()) {
439                 // this is ambigous if two formats have the same extension,
440                 // but better than nothing
441                 Formats::const_iterator cit =
442                         find_if(formatlist.begin(), formatlist.end(),
443                                 FormatExtensionsEqual(ext));
444                 if (cit != formats.end()) {
445                         LYXERR(Debug::GRAPHICS, "\twill guess format from file extension: "
446                                 << ext << " -> " << cit->name());
447                         return cit->name();
448                 }
449         }
450         return string();
451 }
452
453
454 string Formats::getFormatFromPrettyName(string const & prettyname) const
455 {
456         if (!prettyname.empty()) {
457                 Formats::const_iterator cit =
458                         find_if(formatlist.begin(), formatlist.end(),
459                                 FormatPrettyNameEqual(prettyname));
460                 if (cit != formats.end())
461                         return cit->name();
462         }
463         return string();
464 }
465
466
467 /// Used to store last timestamp of file and whether it is (was) zipped
468 struct ZippedInfo {
469         bool zipped;
470         std::time_t timestamp;
471         ZippedInfo(bool zipped, std::time_t timestamp)
472         : zipped(zipped), timestamp(timestamp) { }
473 };
474
475
476 /// Mapping absolute pathnames of files to their ZippedInfo metadata.
477 static std::map<std::string, ZippedInfo> zipped_;
478
479
480 bool Formats::isZippedFile(support::FileName const & filename) const {
481         string const & fname = filename.absFileName();
482         time_t timestamp = filename.lastModified();
483         map<string, ZippedInfo>::iterator it = zipped_.find(fname);
484         if (it != zipped_.end() && it->second.timestamp == timestamp)
485                 return it->second.zipped;
486         string const & format = getFormatFromFile(filename);
487         bool zipped = (format == "gzip" || format == "zip");
488         zipped_.insert(make_pair(fname, ZippedInfo(zipped, timestamp)));
489         return zipped;
490 }
491
492
493 bool Formats::isZippedFileFormat(string const & format)
494 {
495         return contains("gzip zip compress", format) && !format.empty();
496 }
497
498
499 bool Formats::isPostScriptFileFormat(string const & format)
500 {
501         return format == "ps" || format == "eps";
502 }
503
504 static string fixCommand(string const & cmd, string const & ext,
505                   os::auto_open_mode mode)
506 {
507         // configure.py says we do not want a viewer/editor
508         if (cmd.empty())
509                 return cmd;
510
511         // Does the OS manage this format?
512         if (os::canAutoOpenFile(ext, mode))
513                 return "auto";
514
515         // if configure.py found nothing, clear the command
516         if (token(cmd, ' ', 0) == "auto")
517                 return string();
518
519         // use the command found by configure.py
520         return cmd;
521 }
522
523
524 void Formats::setAutoOpen()
525 {
526         FormatList::iterator fit = formatlist.begin();
527         FormatList::iterator const fend = formatlist.end();
528         for ( ; fit != fend ; ++fit) {
529                 fit->setViewer(fixCommand(fit->viewer(), fit->extension(), os::VIEW));
530                 fit->setEditor(fixCommand(fit->editor(), fit->extension(), os::EDIT));
531         }
532 }
533
534
535 int Formats::getNumber(string const & name) const
536 {
537         FormatList::const_iterator cit =
538                 find_if(formatlist.begin(), formatlist.end(),
539                         FormatNamesEqual(name));
540         if (cit != formatlist.end())
541                 return distance(formatlist.begin(), cit);
542         else
543                 return -1;
544 }
545
546
547 void Formats::add(string const & name)
548 {
549         if (!getFormat(name))
550                 add(name, name, name, string(), string(), string(),
551                     string(), Format::document);
552 }
553
554
555 void Formats::add(string const & name, string const & extensions,
556                   string const & prettyname, string const & shortcut,
557                   string const & viewer, string const & editor,
558                   string const & mime, int flags)
559 {
560         FormatList::iterator it =
561                 find_if(formatlist.begin(), formatlist.end(),
562                         FormatNamesEqual(name));
563         if (it == formatlist.end())
564                 formatlist.push_back(Format(name, extensions, prettyname,
565                                             shortcut, viewer, editor, mime, flags));
566         else
567                 *it = Format(name, extensions, prettyname, shortcut, viewer,
568                              editor, mime, flags);
569 }
570
571
572 void Formats::erase(string const & name)
573 {
574         FormatList::iterator it =
575                 find_if(formatlist.begin(), formatlist.end(),
576                         FormatNamesEqual(name));
577         if (it != formatlist.end())
578                 formatlist.erase(it);
579 }
580
581
582 void Formats::sort()
583 {
584         std::sort(formatlist.begin(), formatlist.end());
585 }
586
587
588 void Formats::setViewer(string const & name, string const & command)
589 {
590         add(name);
591         FormatList::iterator it =
592                 find_if(formatlist.begin(), formatlist.end(),
593                         FormatNamesEqual(name));
594         if (it != formatlist.end())
595                 it->setViewer(command);
596 }
597
598
599 void Formats::setEditor(string const & name, string const & command)
600 {
601         add(name);
602         FormatList::iterator it =
603                 find_if(formatlist.begin(), formatlist.end(),
604                         FormatNamesEqual(name));
605         if (it != formatlist.end())
606                 it->setEditor(command);
607 }
608
609
610 bool Formats::view(Buffer const & buffer, FileName const & filename,
611                    string const & format_name) const
612 {
613         if (filename.empty() || !filename.exists()) {
614                 Alert::error(_("Cannot view file"),
615                         bformat(_("File does not exist: %1$s"),
616                                 from_utf8(filename.absFileName())));
617                 return false;
618         }
619
620         Format const * format = getFormat(format_name);
621         if (format && format->viewer().empty() &&
622             format->isChildFormat())
623                 format = getFormat(format->parentFormat());
624         if (!format || format->viewer().empty()) {
625 // FIXME: I believe this is the wrong place to show alerts, it should be done
626 // by the caller (this should be "utility" code)
627                 Alert::error(_("Cannot view file"),
628                         bformat(_("No information for viewing %1$s"),
629                                 prettyName(format_name)));
630                 return false;
631         }
632         // viewer is 'auto'
633         if (format->viewer() == "auto") {
634                 if (os::autoOpenFile(filename.absFileName(), os::VIEW, buffer.filePath()))
635                         return true;
636                 else {
637                         Alert::error(_("Cannot view file"),
638                                 bformat(_("Auto-view file %1$s failed"),
639                                         from_utf8(filename.absFileName())));
640                         return false;
641                 }
642         }
643
644         string command = libScriptSearch(format->viewer());
645
646         if (format_name == "dvi" &&
647             !lyxrc.view_dvi_paper_option.empty()) {
648                 string paper_size = buffer.params().paperSizeName(BufferParams::XDVI);
649                 if (!paper_size.empty()) {
650                         command += ' ' + lyxrc.view_dvi_paper_option;
651                         command += ' ' + paper_size;
652                         if (buffer.params().orientation == ORIENTATION_LANDSCAPE &&
653                             buffer.params().papersize != PAPER_CUSTOM)
654                                 command += 'r';
655                 }
656         }
657
658         if (!contains(command, token_from_format))
659                 command += ' ' + token_from_format;
660
661         command = subst(command, token_from_format, quoteName(onlyFileName(filename.toFilesystemEncoding())));
662         command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding())));
663         command = subst(command, token_socket_format, quoteName(theServerSocket().address()));
664         LYXERR(Debug::FILES, "Executing command: " << command);
665         // FIXME UNICODE utf8 can be wrong for files
666         buffer.message(_("Executing command: ") + from_utf8(command));
667
668         PathChanger p(filename.onlyPath());
669         Systemcall one;
670         one.startscript(Systemcall::DontWait, command, buffer.filePath());
671
672         // we can't report any sort of error, since we aren't waiting
673         return true;
674 }
675
676
677 bool Formats::edit(Buffer const & buffer, FileName const & filename,
678                          string const & format_name) const
679 {
680         if (filename.empty() || !filename.exists()) {
681                 Alert::error(_("Cannot edit file"),
682                         bformat(_("File does not exist: %1$s"),
683                                 from_utf8(filename.absFileName())));
684                 return false;
685         }
686
687         // LinkBack files look like PDF, but have the .linkback extension
688         string const ext = getExtension(filename.absFileName());
689         if (format_name == "pdf6" && ext == "linkback") {
690 #ifdef USE_MACOSX_PACKAGING
691                 return editLinkBackFile(filename.absFileName().c_str());
692 #else
693                 Alert::error(_("Cannot edit file"),
694                              _("LinkBack files can only be edited on Apple Mac OSX."));
695                 return false;
696 #endif // USE_MACOSX_PACKAGING
697         }
698
699         Format const * format = getFormat(format_name);
700         if (format && format->editor().empty() &&
701             format->isChildFormat())
702                 format = getFormat(format->parentFormat());
703         if (!format || format->editor().empty()) {
704 // FIXME: I believe this is the wrong place to show alerts, it should
705 // be done by the caller (this should be "utility" code)
706                 Alert::error(_("Cannot edit file"),
707                         bformat(_("No information for editing %1$s"),
708                                 prettyName(format_name)));
709                 return false;
710         }
711
712         // editor is 'auto'
713         if (format->editor() == "auto") {
714                 if (os::autoOpenFile(filename.absFileName(), os::EDIT, buffer.filePath()))
715                         return true;
716                 else {
717                         Alert::error(_("Cannot edit file"),
718                                 bformat(_("Auto-edit file %1$s failed"),
719                                         from_utf8(filename.absFileName())));
720                         return false;
721                 }
722         }
723
724         string command = format->editor();
725
726         if (!contains(command, token_from_format))
727                 command += ' ' + token_from_format;
728
729         command = subst(command, token_from_format, quoteName(filename.toFilesystemEncoding()));
730         command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding())));
731         command = subst(command, token_socket_format, quoteName(theServerSocket().address()));
732         LYXERR(Debug::FILES, "Executing command: " << command);
733         // FIXME UNICODE utf8 can be wrong for files
734         buffer.message(_("Executing command: ") + from_utf8(command));
735
736         Systemcall one;
737         one.startscript(Systemcall::DontWait, command, buffer.filePath());
738
739         // we can't report any sort of error, since we aren't waiting
740         return true;
741 }
742
743
744 docstring const Formats::prettyName(string const & name) const
745 {
746         Format const * format = getFormat(name);
747         if (format)
748                 return from_utf8(format->prettyname());
749         else
750                 return from_utf8(name);
751 }
752
753
754 string const Formats::extension(string const & name) const
755 {
756         Format const * format = getFormat(name);
757         if (format)
758                 return format->extension();
759         else
760                 return name;
761 }
762
763
764 string const Formats::extensions(string const & name) const
765 {
766         Format const * format = getFormat(name);
767         if (format)
768                 return format->extensions();
769         else
770                 return name;
771 }
772
773
774 namespace {
775
776 typedef Translator<OutputParams::FLAVOR, string> FlavorTranslator;
777
778
779 FlavorTranslator initFlavorTranslator()
780 {
781         FlavorTranslator f(OutputParams::LATEX, "latex");
782         f.addPair(OutputParams::DVILUATEX, "dviluatex");
783         f.addPair(OutputParams::LUATEX, "luatex");
784         f.addPair(OutputParams::PDFLATEX, "pdflatex");
785         f.addPair(OutputParams::XETEX, "xetex");
786         f.addPair(OutputParams::XML, "docbook-xml");
787         f.addPair(OutputParams::HTML, "xhtml");
788         f.addPair(OutputParams::TEXT, "text");
789         return f;
790 }
791
792
793 FlavorTranslator const & flavorTranslator()
794 {
795         static FlavorTranslator translator = initFlavorTranslator();
796         return translator;
797 }
798
799 }
800
801
802 std::string flavor2format(OutputParams::FLAVOR flavor)
803 {
804         return flavorTranslator().find(flavor);
805 }
806
807
808 /* Not currently needed, but I'll leave the code in case it is.
809 OutputParams::FLAVOR format2flavor(std::string fmt)
810 {
811         return flavorTranslator().find(fmt);
812 } */
813
814 Formats formats;
815
816 Formats system_formats;
817
818
819 } // namespace lyx