3 * \file LaTeXFeatures.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
13 #ifndef LATEXFEATURES_H
14 #define LATEXFEATURES_H
16 #include "OutputParams.h"
17 #include "support/docstring.h"
31 /** The packages and commands that a buffer needs. This class
32 * contains a list<string>. Each of the LaTeX packages that a buffer needs
33 * should be added with void require(string const & name).
35 * i.e require("amssymb")
37 * To add support you should only need to require() the package name as
38 * packages which don't have special requirements are handled automatically.
39 * If your new package does need special consideration you'll need to alter
40 * string const getPackages() const;
41 * Remember to update the validate function in Buffer.cpp and Paragraph.cpp
47 LaTeXFeatures(Buffer const &, BufferParams const &,
48 OutputParams const &);
49 /// The color packages
50 std::string const getColorOptions() const;
51 /// The packages needed by the document
52 std::string const getPackages() const;
53 /// The macros definitions needed by the document
54 docstring const getMacros() const;
55 /// Extra preamble code before babel is called
56 std::string const getBabelPresettings() const;
57 /// Extra preamble code after babel is called
58 std::string const getBabelPostsettings() const;
59 /// Do we need to pass the languages to babel directly?
60 bool needBabelLangOptions() const;
61 /// Load AMS packages when appropriate
62 std::string const loadAMSPackages() const;
63 /// The definitions needed by the document's textclass
64 docstring const getTClassPreamble() const;
65 /// The language dependent definitions needed by the document's textclass
66 docstring const getTClassI18nPreamble(bool use_babel, bool use_polyglossia) const;
68 docstring const getTClassHTMLStyles() const;
70 docstring const getTClassHTMLPreamble() const;
71 /// The sgml definitions needed by the document (docbook)
72 docstring const getLyXSGMLEntities() const;
73 /// The SGML Required to include the files added with includeFile();
74 docstring const getIncludedFiles(std::string const & fname) const;
75 /// Include a file for use with the SGML entities
76 void includeFile(docstring const & key, std::string const & name);
77 /// The float definitions.
78 void getFloatDefinitions(odocstream & os) const;
79 /// Print requirements to lyxerr
80 void showStruct() const;
82 void addPreambleSnippet(std::string const &);
84 std::string getPreambleSnippets() const;
86 void addCSSSnippet(std::string const &);
88 std::string getCSSSnippets() const;
89 /// Add a feature name requirements
90 void require(std::string const & name);
91 /// Add a set of feature names requirements
92 void require(std::set<std::string> const & names);
93 /// Is the (required) package available?
94 static bool isAvailable(std::string const & name);
95 /// Has the package been required?
96 bool isRequired(std::string const & name) const;
97 /* Is it necessary to load the package? This is true if
98 isRequired is true and the feature is not provided by the
101 bool mustProvide(std::string const & name) const;
103 void useFloat(std::string const & name, bool subfloat = false);
105 void useLanguage(Language const *);
107 bool hasLanguages() const;
108 /// check if all used languages are supported by polyglossia
109 bool hasOnlyPolyglossiaLanguages() const;
110 /// check if a language is supported only by polyglossia
111 bool hasPolyglossiaExclusiveLanguages() const;
113 std::string getLanguages() const;
115 std::map<std::string, std::string> getPolyglossiaLanguages() const;
117 std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
119 void useLayout(docstring const & lyt);
121 void useInsetLayout(InsetLayout const & lay);
123 Buffer const & buffer() const;
125 void setBuffer(Buffer const &);
127 BufferParams const & bufferParams() const;
128 /// the return value is dependent upon both LyXRC and LaTeXFeatures.
129 bool useBabel() const;
131 bool usePolyglossia() const;
132 /// are we in a float?
133 bool inFloat() const { return in_float_; }
134 /// are we in a float?
135 void inFloat(bool const b) { in_float_ = b; }
136 /// Runparams that will be used for exporting this file.
137 OutputParams const & runparams() const { return runparams_; }
138 /// Resolve alternatives like "esint|amsmath|wasysym"
139 void resolveAlternatives();
141 void setHTMLTitle(docstring const & t) { htmltitle_ = t; }
143 docstring const & htmlTitle() const { return htmltitle_; }
147 std::list<docstring> usedLayouts_;
149 std::list<docstring> usedInsetLayouts_;
150 /// The features that are needed by the document
151 typedef std::set<std::string> Features;
154 /// Static preamble bits, from external templates, or anywhere else
155 typedef std::list<std::string> SnippetList;
157 SnippetList preamble_snippets_;
159 SnippetList css_snippets_;
161 typedef std::set<Language const *> LanguageList;
162 /// used languages (only those that are supported by babel)
163 LanguageList UsedLanguages_;
165 typedef std::map<std::string, bool> UsedFloats;
167 UsedFloats usedFloats_;
169 typedef std::map<docstring, std::string> FileMap;
171 FileMap IncludedFiles_;
172 /** Buffer of the file being processed.
173 * This may be a child buffer of the to-be-exported file and
174 * therefore may not be the buffer that belongs to params_.
175 * Only needed by InsetInclude::validate().
177 Buffer const * buffer_;
179 BufferParams const & params_;
180 /** Some insets need to know details about the to-be-produced file
183 OutputParams const & runparams_;
187 docstring htmltitle_;