+
+void LaTeXFeatures::addExternalPreamble(string const & pream)
+{
+ externalPreambles += pream;
+}
+
+
+void LaTeXFeatures::useFloat(string const & name)
+{
+ usedFloats.insert(name);
+ // We only need float.sty if we use non builtin floats, or if we
+ // use the "H" modifier. This includes modified table and
+ // figure floats. (Lgb)
+ Floating const & fl = params.getLyXTextClass().floats().getType(name);
+ if (!fl.type().empty() && !fl.builtin()) {
+ require("float");
+ }
+}
+
+
+void LaTeXFeatures::useLanguage(Language const * lang)
+{
+ UsedLanguages.insert(lang);
+}
+
+
+void LaTeXFeatures::includeFile(string const & key, string const & name)
+{
+ IncludedFiles[key] = name;
+}
+
+
+bool LaTeXFeatures::hasLanguages() const
+{
+ return !UsedLanguages.empty();
+}
+
+
+string LaTeXFeatures::getLanguages() const
+{
+ ostringstream languages;
+
+ for (LanguageList::const_iterator cit =
+ UsedLanguages.begin();
+ cit != UsedLanguages.end();
+ ++cit)
+ languages << (*cit)->babel() << ',';
+
+ return STRCONV(languages.str());
+}
+
+
+set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding) const
+{
+ set<string> encodings;
+ for (LanguageList::const_iterator it =
+ UsedLanguages.begin();
+ it != UsedLanguages.end(); ++it)
+ if ((*it)->encoding()->LatexName() != doc_encoding)
+ encodings.insert((*it)->encoding()->LatexName());
+ return encodings;
+}
+
+namespace {
+
+char const * simplefeatures[] = {
+ "array",
+ "verbatim",
+ "longtable",
+ "rotating",
+ "latexsym",
+ "pifont",
+ "subfigure",
+ "floatflt",
+ "varioref",
+ "prettyref",
+ "float",
+ "wasy",
+ "dvipost"
+};
+
+int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
+
+}
+
+
+string const LaTeXFeatures::getPackages() const
+{
+ ostringstream packages;
+ LyXTextClass const & tclass = params.getLyXTextClass();
+
+ //
+ // These are all the 'simple' includes. i.e
+ // packages which we just \usepackage{package}
+ //
+ for (int i = 0; i < nb_simplefeatures; ++i) {
+ if (isRequired(simplefeatures[i]))
+ packages << "\\usepackage{"
+ << simplefeatures[i] << "}\n";
+ }
+
+ //
+ // The rest of these packages are somewhat more complicated
+ // than those above.
+ //
+
+ if (isRequired("amsmath")
+ && !tclass.provides(LyXTextClass::amsmath)
+ && params.use_amsmath != BufferParams::AMS_OFF) {
+ packages << "\\usepackage{amsmath}\n";
+ }