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"
17 #include "support/trivstring.h"
26 namespace support { class FileName; }
39 Converter(std::string const & f, std::string const & t, std::string const & c,
40 std::string const & l);
44 std::string const from() const { return from_; }
46 std::string const to() const { return to_; }
48 std::string const command() const { return command_; }
50 void setCommand(std::string const & command) { command_ = command; }
52 std::string const flags() const { return flags_; }
54 void setFlags(std::string const & flags) { flags_ = flags; }
56 Format const * From() const { return From_; }
58 void setFrom(Format const * From) { From_ = From; }
60 void setTo(Format const * To) { To_ = To; }
62 Format const * To() const { return To_; }
64 bool latex() const { return latex_; }
66 std::string const latex_flavor() const { return latex_flavor_; }
68 bool xml() const { return xml_; }
70 bool need_aux() const { return need_aux_; }
72 bool nice() const { return nice_; }
74 std::string const result_dir() const { return result_dir_; }
76 std::string const result_file() const { return result_file_; }
78 std::string const parselog() const { return parselog_; }
93 /// The converter is latex or its derivatives
95 /// The latex derivate
96 trivstring latex_flavor_;
97 /// The converter is xml
99 /// This converter needs the .aux files
101 /// we need a "nice" file from the backend, c.f. OutputParams.nice.
103 /// If the converter put the result in a directory, then result_dir
104 /// is the name of the directory
105 trivstring result_dir_;
106 /// If the converter put the result in a directory, then result_file
107 /// is the name of the main file in that directory
108 trivstring result_file_;
109 /// Command to convert the program output to a LaTeX log file format
110 trivstring parselog_;
118 typedef std::vector<Converter> ConverterList;
120 typedef ConverterList::const_iterator const_iterator;
123 Converter const & get(int i) const { return converterlist_[i]; }
125 Converter const * getConverter(std::string const & from,
126 std::string const & to) const;
128 int getNumber(std::string const & from, std::string const & to) const;
130 void add(std::string const & from, std::string const & to,
131 std::string const & command, std::string const & flags);
133 void erase(std::string const & from, std::string const & to);
135 std::vector<Format const *> const
136 getReachableTo(std::string const & target, bool clear_visited);
138 std::vector<Format const *> const
139 getReachable(std::string const & from, bool only_viewable,
141 std::set<std::string> const & excludes = std::set<std::string>());
143 std::vector<Format const *> importableFormats();
144 std::vector<Format const *> exportableFormats(bool only_viewable);
146 std::vector<std::string> loaders() const;
147 std::vector<std::string> savers() const;
149 /// Does a conversion path from format \p from to format \p to exist?
150 bool isReachable(std::string const & from, std::string const & to);
152 Graph::EdgePath getPath(std::string const & from, std::string const & to);
154 OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path,
155 Buffer const * buffer = 0);
156 /// Flags for converting files
157 enum ConversionFlags {
160 /// Use the default converter if no converter is defined
161 try_default = 1 << 0,
162 /// Get the converted file from cache if possible
166 bool convert(Buffer const * buffer,
167 support::FileName const & from_file, support::FileName const & to_file,
168 support::FileName const & orig_from,
169 std::string const & from_format, std::string const & to_format,
170 ErrorList & errorList, int conversionflags = none);
172 void update(Formats const & formats);
174 void updateLast(Formats const & formats);
176 bool formatIsUsed(std::string const & format);
178 const_iterator begin() const { return converterlist_.begin(); }
180 const_iterator end() const { return converterlist_.end(); }
185 std::vector<Format const *> const
186 intToFormat(std::vector<int> const & input);
188 bool scanLog(Buffer const & buffer, std::string const & command,
189 support::FileName const & filename, ErrorList & errorList);
191 bool runLaTeX(Buffer const & buffer, std::string const & command,
192 OutputParams const &, ErrorList & errorList);
194 ConverterList converterlist_;
196 trivstring latex_command_;
198 trivstring dvilualatex_command_;
200 trivstring lualatex_command_;
202 trivstring pdflatex_command_;
204 trivstring xelatex_command_;
205 /// If \p from = /path/file.ext and \p to = /path2/file2.ext2 then
206 /// this method moves each /path/file*.ext file to /path2/file2*.ext2
207 bool move(std::string const & fmt,
208 support::FileName const & from, support::FileName const & to,
214 /// The global instance.
215 /// Implementation is in LyX.cpp.
216 extern Converters & theConverters();
218 /// The global copy after reading lyxrc.defaults.
219 /// Implementation is in LyX.cpp.
220 extern Converters & theSystemConverters();