+ formats.add(from);
+ formats.add(to);
+ ConverterList::iterator it = find_if(converterlist_.begin(),
+ converterlist_.end(),
+ compare_Converter(from, to));
+
+ Converter converter(from, to, command, flags);
+ if (it != converterlist_.end() && !flags.empty() && flags[0] == '*') {
+ converter = *it;
+ converter.command = command;
+ converter.flags = flags;
+ }
+ converter.readFlags();
+
+ if (converter.latex && (latex_command_.empty() || to == "dvi"))
+ latex_command_ = subst(command, token_from, "");
+ // If we have both latex & pdflatex, we set latex_command to latex.
+ // The latex_command is used to update the .aux file when running
+ // a converter that uses it.
+
+ if (it == converterlist_.end()) {
+ converterlist_.push_back(converter);
+ } else {
+ converter.From = it->From;
+ converter.To = it->To;
+ *it = converter;
+ }
+}
+
+
+void Converters::erase(string const & from, string const & to)
+{
+ ConverterList::iterator it = find_if(converterlist_.begin(),
+ converterlist_.end(),
+ compare_Converter(from, to));
+ if (it != converterlist_.end())
+ converterlist_.erase(it);
+}
+
+
+// This method updates the pointers From and To in all the converters.
+// The code is not very efficient, but it doesn't matter as the number
+// of formats and converters is small.
+// Furthermore, this method is called only on startup, or after
+// adding/deleting a format in FormPreferences (the latter calls can be
+// eliminated if the formats in the Formats class are stored using a map or
+// a list (instead of a vector), but this will cause other problems).
+void Converters::update(Formats const & formats)
+{
+ ConverterList::iterator it = converterlist_.begin();
+ ConverterList::iterator end = converterlist_.end();
+ for (; it != end; ++it) {
+ it->From = formats.getFormat(it->from);
+ it->To = formats.getFormat(it->to);
+ }
+}
+
+
+// This method updates the pointers From and To in the last converter.
+// It is called when adding a new converter in FormPreferences
+void Converters::updateLast(Formats const & formats)
+{
+ if (converterlist_.begin() != converterlist_.end()) {
+ ConverterList::iterator it = converterlist_.end() - 1;
+ it->From = formats.getFormat(it->from);
+ it->To = formats.getFormat(it->to);
+ }
+}
+