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"
32 /** The packages and commands that a buffer needs. This class
33 * contains a list<string>. Each of the LaTeX packages that a buffer needs
34 * should be added with void require(string const & name).
36 * i.e require("amssymb")
38 * To add support you should only need to require() the package name as
39 * packages which don't have special requirements are handled automatically.
40 * If your new package does need special consideration you'll need to alter
41 * string const getPackages() const;
42 * Remember to update the validate function in Buffer.cpp and Paragraph.cpp
48 LaTeXFeatures(Buffer const &, BufferParams const &,
49 OutputParams const &);
50 /// The color packages
51 std::string const getColorOptions() const;
52 /// The packages needed by the document
53 std::string const getPackages() const;
54 /// The macros definitions needed by the document
55 std::string const getMacros() const;
57 std::string const getBabelOptions() const;
58 /// The definitions needed by the document's textclass
59 docstring const getTClassPreamble() const;
60 /// The language dependent definitions needed by the document's textclass
61 docstring const getTClassI18nPreamble(bool use_babel) const;
63 docstring const getTClassHTMLStyles() const;
65 docstring const getTClassHTMLPreamble() const;
66 /// The sgml definitions needed by the document (docbook)
67 docstring const getLyXSGMLEntities() const;
68 /// The SGML Required to include the files added with includeFile();
69 docstring const getIncludedFiles(std::string const & fname) const;
70 /// Include a file for use with the SGML entities
71 void includeFile(docstring const & key, std::string const & name);
72 /// The float definitions.
73 void getFloatDefinitions(std::ostream & os) const;
74 /// Print requirements to lyxerr
75 void showStruct() const;
77 void addPreambleSnippet(std::string const &);
78 /// Add a feature name requirements
79 void require(std::string const & name);
80 /// Add a set of feature names requirements
81 void require(std::set<std::string> const & names);
82 /// Which of the required packages are installed?
83 static void getAvailable();
84 /// Is the (required) package available?
85 static bool isAvailable(std::string const & name);
86 /// Has the package been required?
87 bool isRequired(std::string const & name) const;
88 /* Is it necessary to load the package? This is true if
89 isRequired is true and the feature is not provided by the
92 bool mustProvide(std::string const & name) const;
94 void useFloat(std::string const & name, bool subfloat = false);
96 void useLanguage(Language const *);
98 bool hasLanguages() const;
100 std::string getLanguages() const;
102 std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
104 void useLayout(docstring const & lyt);
106 void useInsetLayout(InsetLayout const & lay);
108 Buffer const & buffer() const;
110 void setBuffer(Buffer const &);
112 BufferParams const & bufferParams() const;
113 /// the return value is dependent upon both LyXRC and LaTeXFeatures.
114 bool useBabel() const;
115 /// are we in a float?
116 bool inFloat() const { return in_float_; }
117 /// are we in a float?
118 void inFloat(bool const b) { in_float_ = b; }
119 /// Runparams that will be used for exporting this file.
120 OutputParams const & runparams() const { return runparams_; }
124 std::list<docstring> usedLayouts_;
126 std::list<docstring> usedInsetLayouts_;
127 /// The features that are needed by the document
128 typedef std::set<std::string> Features;
131 /// Static preamble bits from the external material insets
132 typedef std::list<std::string> SnippetList;
134 SnippetList preamble_snippets_;
135 /// The available (required) packages
136 typedef std::set<std::string> Packages;
138 static Packages packages_;
140 typedef std::set<Language const *> LanguageList;
141 /// used languages (only those that are supported by babel)
142 LanguageList UsedLanguages_;
144 typedef std::map<std::string, bool> UsedFloats;
146 UsedFloats usedFloats_;
148 typedef std::map<docstring, std::string> FileMap;
150 FileMap IncludedFiles_;
151 /** Buffer of the file being processed.
152 * This may be a child buffer of the to-be-exported file and
153 * therefore may not be the buffer that belongs to params_.
154 * Only needed by InsetInclude::validate().
156 Buffer const * buffer_;
158 BufferParams const & params_;
159 /** Some insets need to know details about the to-be-produced file
162 OutputParams const & runparams_;