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"
24 namespace support { class FileName; }
37 Converter(std::string const & f, std::string const & t, std::string const & c,
38 std::string const & l);
54 /// The converter is latex or its derivatives
56 /// The converter is xml
58 /// This converter needs the .aux files
60 /// If the converter put the result in a directory, then result_dir
61 /// is the name of the directory
62 std::string result_dir;
63 /// If the converter put the result in a directory, then result_file
64 /// is the name of the main file in that directory
65 std::string result_file;
66 /// Command to convert the program output to a LaTeX log file format
75 typedef std::vector<int> EdgePath; // to be removed SOON
77 typedef std::vector<Converter> ConverterList;
79 typedef ConverterList::const_iterator const_iterator;
81 Converter const & get(int i) const { return converterlist_[i]; }
83 Converter const * getConverter(std::string const & from,
84 std::string const & to) const;
86 int getNumber(std::string const & from, std::string const & to) const;
88 void add(std::string const & from, std::string const & to,
89 std::string const & command, std::string const & flags);
91 void erase(std::string const & from, std::string const & to);
95 std::vector<Format const *> const
96 getReachableTo(std::string const & target, bool clear_visited);
98 std::vector<Format const *> const
99 getReachable(std::string const & from, bool only_viewable,
101 /// Does a conversion path from format \p from to format \p to exist?
102 bool isReachable(std::string const & from, std::string const & to);
104 Graph::EdgePath const getPath(std::string const & from, std::string const & to);
106 OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path);
107 /// Flags for converting files
108 enum ConversionFlags {
111 /// Use the default converter if no converter is defined
112 try_default = 1 << 0,
113 /// Get the converted file from cache if possible
117 bool convert(Buffer const * buffer,
118 support::FileName const & from_file, support::FileName const & to_file,
119 support::FileName const & orig_from,
120 std::string const & from_format, std::string const & to_format,
121 ErrorList & errorList, int conversionflags = none);
123 void update(Formats const & formats);
125 void updateLast(Formats const & formats);
127 bool formatIsUsed(std::string const & format);
129 const_iterator begin() const { return converterlist_.begin(); }
131 const_iterator end() const { return converterlist_.end(); }
136 std::vector<Format const *> const
137 intToFormat(std::vector<int> const & input);
139 bool scanLog(Buffer const & buffer, std::string const & command,
140 support::FileName const & filename, ErrorList & errorList);
142 bool runLaTeX(Buffer const & buffer, std::string const & command,
143 OutputParams const &, ErrorList & errorList);
145 ConverterList converterlist_;
147 std::string latex_command_;
148 /// If \p from = /path/file.ext and \p to = /path2/file2.ext2 then
149 /// this method moves each /path/file*.ext file to /path2/file2*.ext2
150 bool move(std::string const & fmt,
151 support::FileName const & from, support::FileName const & to,
157 /// The global instance.
158 /// Implementation is in LyX.cpp.
159 extern Converters & theConverters();
161 /// The global copy after reading lyxrc.defaults.
162 /// Implementation is in LyX.cpp.
163 extern Converters & theSystemConverters();