4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "OutputParams.h"
25 namespace support { class FileName; }
38 Converter(std::string const & f, std::string const & t, std::string const & c,
39 std::string const & l);
55 /// The converter is latex or its derivatives
57 /// The latex derivate
58 std::string latex_flavor;
59 /// The converter is xml
61 /// This converter needs the .aux files
63 /// If the converter put the result in a directory, then result_dir
64 /// is the name of the directory
65 std::string result_dir;
66 /// If the converter put the result in a directory, then result_file
67 /// is the name of the main file in that directory
68 std::string result_file;
69 /// Command to convert the program output to a LaTeX log file format
78 typedef std::vector<Converter> ConverterList;
80 typedef ConverterList::const_iterator const_iterator;
82 typedef std::vector<std::string> FormatList;
85 Converter const & get(int i) const { return converterlist_[i]; }
87 Converter const * getConverter(std::string const & from,
88 std::string const & to) const;
90 int getNumber(std::string const & from, std::string const & to) const;
92 void add(std::string const & from, std::string const & to,
93 std::string const & command, std::string const & flags);
95 void erase(std::string const & from, std::string const & to);
99 std::vector<Format const *> const
100 getReachableTo(std::string const & target, bool clear_visited);
102 std::vector<Format const *> const
103 getReachable(std::string const & from, bool only_viewable,
105 std::set<std::string> const & excludes = std::set<std::string>());
107 std::vector<Format const *> importableFormats();
108 std::vector<Format const *> exportableFormats(bool only_viewable);
110 std::vector<std::string> loaders() const;
111 std::vector<std::string> savers() const;
113 /// Does a conversion path from format \p from to format \p to exist?
114 bool isReachable(std::string const & from, std::string const & to);
116 Graph::EdgePath getPath(std::string const & from, std::string const & to);
118 OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path);
119 /// Flags for converting files
120 enum ConversionFlags {
123 /// Use the default converter if no converter is defined
124 try_default = 1 << 0,
125 /// Get the converted file from cache if possible
129 bool convert(Buffer const * buffer,
130 support::FileName const & from_file, support::FileName const & to_file,
131 support::FileName const & orig_from,
132 std::string const & from_format, std::string const & to_format,
133 ErrorList & errorList, int conversionflags = none);
135 void update(Formats const & formats);
137 void updateLast(Formats const & formats);
139 bool formatIsUsed(std::string const & format);
141 const_iterator begin() const { return converterlist_.begin(); }
143 const_iterator end() const { return converterlist_.end(); }
148 std::vector<Format const *> const
149 intToFormat(std::vector<int> const & input);
151 bool scanLog(Buffer const & buffer, std::string const & command,
152 support::FileName const & filename, ErrorList & errorList);
154 bool runLaTeX(Buffer const & buffer, std::string const & command,
155 OutputParams const &, ErrorList & errorList);
157 ConverterList converterlist_;
159 std::string latex_command_;
161 std::string xelatex_command_;
162 /// If \p from = /path/file.ext and \p to = /path2/file2.ext2 then
163 /// this method moves each /path/file*.ext file to /path2/file2*.ext2
164 bool move(std::string const & fmt,
165 support::FileName const & from, support::FileName const & to,
171 /// The global instance.
172 /// Implementation is in LyX.cpp.
173 extern Converters & theConverters();
175 /// The global copy after reading lyxrc.defaults.
176 /// Implementation is in LyX.cpp.
177 extern Converters & theSystemConverters();