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; }
38 Converter(std::string const & f, std::string const & t, std::string const & c,
39 std::string const & l);
43 std::string const from() const { return from_; }
45 std::string const to() const { return to_; }
47 std::string const command() const { return command_; }
49 void setCommand(std::string const & command) { command_ = command; }
51 std::string const flags() const { return flags_; }
53 void setFlags(std::string const & flags) { flags_ = flags; }
55 Format const * From() const { return From_; }
57 void setFrom(Format const * From) { From_ = From; }
59 void setTo(Format const * To) { To_ = To; }
61 Format const * To() const { return To_; }
63 bool latex() const { return latex_; }
65 std::string const latex_flavor() const { return latex_flavor_; }
67 bool xml() const { return xml_; }
69 bool need_aux() const { return need_aux_; }
71 bool nice() const { return nice_; }
73 std::string const result_dir() const { return result_dir_; }
75 std::string const result_file() const { return result_file_; }
77 std::string const parselog() const { return parselog_; }
92 /// The converter is latex or its derivatives
94 /// The latex derivate
95 trivstring latex_flavor_;
96 /// The converter is xml
98 /// This converter needs the .aux files
100 /// we need a "nice" file from the backend, c.f. OutputParams.nice.
102 /// If the converter put the result in a directory, then result_dir
103 /// is the name of the directory
104 trivstring result_dir_;
105 /// If the converter put the result in a directory, then result_file
106 /// is the name of the main file in that directory
107 trivstring result_file_;
108 /// Command to convert the program output to a LaTeX log file format
109 trivstring parselog_;
117 typedef std::vector<Converter> ConverterList;
119 typedef ConverterList::const_iterator const_iterator;
122 Converter const & get(int i) const { return converterlist_[i]; }
124 Converter const * getConverter(std::string const & from,
125 std::string const & to) const;
127 int getNumber(std::string const & from, std::string const & to) const;
129 void add(std::string const & from, std::string const & to,
130 std::string const & command, std::string const & flags);
132 void erase(std::string const & from, std::string const & to);
134 std::vector<Format const *> const
135 getReachableTo(std::string const & target, bool clear_visited);
137 std::vector<Format const *> const
138 getReachable(std::string const & from, bool only_viewable,
140 std::set<std::string> const & excludes = std::set<std::string>());
142 std::vector<Format const *> importableFormats();
143 std::vector<Format const *> exportableFormats(bool only_viewable);
145 std::vector<std::string> loaders() const;
146 std::vector<std::string> savers() const;
148 /// Does a conversion path from format \p from to format \p to exist?
149 bool isReachable(std::string const & from, std::string const & to);
151 Graph::EdgePath getPath(std::string const & from, std::string const & to);
153 OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path,
154 Buffer const * buffer = 0);
155 /// Flags for converting files
156 enum ConversionFlags {
159 /// Use the default converter if no converter is defined
160 try_default = 1 << 0,
161 /// Get the converted file from cache if possible
165 bool convert(Buffer const * buffer,
166 support::FileName const & from_file, support::FileName const & to_file,
167 support::FileName const & orig_from,
168 std::string const & from_format, std::string const & to_format,
169 ErrorList & errorList, int conversionflags = none);
171 void update(Formats const & formats);
173 void updateLast(Formats const & formats);
175 bool formatIsUsed(std::string const & format);
177 const_iterator begin() const { return converterlist_.begin(); }
179 const_iterator end() const { return converterlist_.end(); }
184 std::vector<Format const *> const
185 intToFormat(std::vector<int> const & input);
187 bool scanLog(Buffer const & buffer, std::string const & command,
188 support::FileName const & filename, ErrorList & errorList);
190 bool runLaTeX(Buffer const & buffer, std::string const & command,
191 OutputParams const &, ErrorList & errorList);
193 ConverterList converterlist_;
195 trivstring latex_command_;
197 trivstring dvilualatex_command_;
199 trivstring lualatex_command_;
201 trivstring pdflatex_command_;
203 trivstring xelatex_command_;
204 /// If \p from = /path/file.ext and \p to = /path2/file2.ext2 then
205 /// this method moves each /path/file*.ext file to /path2/file2*.ext2
206 bool move(std::string const & fmt,
207 support::FileName const & from, support::FileName const & to,
213 /// The global instance.
214 /// Implementation is in LyX.cpp.
215 extern Converters & theConverters();
217 /// The global copy after reading lyxrc.defaults.
218 /// Implementation is in LyX.cpp.
219 extern Converters & theSystemConverters();