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 getTClassHTMLPreamble() const;
64 /// The sgml definitions needed by the document (docbook)
65 docstring const getLyXSGMLEntities() const;
66 /// The SGML Required to include the files added with includeFile();
67 docstring const getIncludedFiles(std::string const & fname) const;
68 /// Include a file for use with the SGML entities
69 void includeFile(docstring const & key, std::string const & name);
70 /// The float definitions.
71 void getFloatDefinitions(std::ostream & os) const;
72 /// Print requirements to lyxerr
73 void showStruct() const;
75 void addPreambleSnippet(std::string const &);
76 /// Add a feature name requirements
77 void require(std::string const & name);
78 /// Add a set of feature names requirements
79 void require(std::set<std::string> const & names);
80 /// Which of the required packages are installed?
81 static void getAvailable();
82 /// Is the (required) package available?
83 static bool isAvailable(std::string const & name);
84 /// Has the package been required?
85 bool isRequired(std::string const & name) const;
86 /* Is it necessary to load the package? This is true if
87 isRequired is true and the feature is not provided by the
90 bool mustProvide(std::string const & name) const;
92 void useFloat(std::string const & name, bool subfloat = false);
94 void useLanguage(Language const *);
96 bool hasLanguages() const;
98 std::string getLanguages() const;
100 std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
102 void useLayout(docstring const & lyt);
104 void useInsetLayout(InsetLayout const & lay);
106 Buffer const & buffer() const;
108 void setBuffer(Buffer const &);
110 BufferParams const & bufferParams() const;
111 /// the return value is dependent upon both LyXRC and LaTeXFeatures.
112 bool useBabel() const;
113 /// are we in a float?
114 bool inFloat() const { return in_float_; }
115 /// are we in a float?
116 void inFloat(bool const b) { in_float_ = b; }
117 /// Runparams that will be used for exporting this file.
118 OutputParams const & runparams() const { return runparams_; }
122 std::list<docstring> usedLayouts_;
124 std::list<docstring> usedInsetLayouts_;
125 /// The features that are needed by the document
126 typedef std::set<std::string> Features;
129 /// Static preamble bits from the external material insets
130 typedef std::list<std::string> SnippetList;
132 SnippetList preamble_snippets_;
133 /// The available (required) packages
134 typedef std::set<std::string> Packages;
136 static Packages packages_;
138 typedef std::set<Language const *> LanguageList;
139 /// used languages (only those that are supported by babel)
140 LanguageList UsedLanguages_;
142 typedef std::map<std::string, bool> UsedFloats;
144 UsedFloats usedFloats_;
146 typedef std::map<docstring, std::string> FileMap;
148 FileMap IncludedFiles_;
149 /** Buffer of the file being processed.
150 * This may be a child buffer of the to-be-exported file and
151 * therefore may not be the buffer that belongs to params_.
152 * Only needed by InsetInclude::validate().
154 Buffer const * buffer_;
156 BufferParams const & params_;
157 /** Some insets need to know details about the to-be-produced file
160 OutputParams const & runparams_;