]> git.lyx.org Git - lyx.git/blob - src/LaTeXFeatures.h
* add PreBabelPreamble to Language definition (fixes #4786).
[lyx.git] / src / LaTeXFeatures.h
1 // -*- C++ -*-
2 /**
3  * \file LaTeXFeatures.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef LATEXFEATURES_H
14 #define LATEXFEATURES_H
15
16 #include "OutputParams.h"
17 #include "support/docstring.h"
18
19 #include <set>
20 #include <list>
21 #include <map>
22
23
24 namespace lyx {
25
26 class Buffer;
27 class BufferParams;
28 class InsetLayout;
29 class Language;
30
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).
34  *
35  *  i.e require("amssymb")
36  *
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
42  *  when you do so.
43  */
44 class LaTeXFeatures {
45 public:
46         ///
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         /// The definitions needed by the document's textclass
60         docstring const getTClassPreamble() const;
61         /// The language dependent definitions needed by the document's textclass
62         docstring const getTClassI18nPreamble(bool use_babel) const;
63         ///
64         docstring const getTClassHTMLStyles() const;
65         ///
66         docstring const getTClassHTMLPreamble() const;
67         /// The sgml definitions needed by the document (docbook)
68         docstring const getLyXSGMLEntities() const;
69         /// The SGML Required to include the files added with includeFile();
70         docstring const getIncludedFiles(std::string const & fname) const;
71         /// Include a file for use with the SGML entities
72         void includeFile(docstring const & key, std::string const & name);
73         /// The float definitions.
74         void getFloatDefinitions(odocstream & os) const;
75         /// Print requirements to lyxerr
76         void showStruct() const;
77         ///
78         void addPreambleSnippet(std::string const &);
79         ///
80         std::string getPreambleSnippets() const;
81         /// Add a feature name requirements
82         void require(std::string const & name);
83         /// Add a set of feature names requirements
84         void require(std::set<std::string> const & names);
85         /// Which of the required packages are installed?
86         static void getAvailable();
87         /// Is the (required) package available?
88         static bool isAvailable(std::string const & name);
89         /// Has the package been required?
90         bool isRequired(std::string const & name) const;
91         /* Is it necessary to load the package? This is true if
92            isRequired is true and the feature is not provided by the
93            textclass.
94         */
95         bool mustProvide(std::string const & name) const;
96         ///
97         void useFloat(std::string const & name, bool subfloat = false);
98         ///
99         void useLanguage(Language const *);
100         ///
101         bool hasLanguages() const;
102         ///
103         std::string getLanguages() const;
104         ///
105         std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
106         ///
107         void useLayout(docstring const & lyt);
108         ///
109         void useInsetLayout(InsetLayout const & lay);
110         ///
111         Buffer const & buffer() const;
112         ///
113         void setBuffer(Buffer const &);
114         ///
115         BufferParams const & bufferParams() const;
116         /// the return value is dependent upon both LyXRC and LaTeXFeatures.
117         bool useBabel() const;
118         /// are we in a float?
119         bool inFloat() const { return in_float_; }
120         /// are we in a float?
121         void inFloat(bool const b) { in_float_ = b; }
122         /// Runparams that will be used for exporting this file.
123         OutputParams const & runparams() const { return runparams_; }
124         ///
125         void setHTMLTitle(docstring const & t) { htmltitle_ = t; }
126         ///
127         docstring const & htmlTitle() const { return htmltitle_; }
128
129 private:
130         ///
131         std::list<docstring> usedLayouts_;
132         ///
133         std::list<docstring> usedInsetLayouts_;
134         /// The features that are needed by the document
135         typedef std::set<std::string> Features;
136         ///
137         Features features_;
138         /// Static preamble bits, from external templates, or anywhere else
139         typedef std::list<std::string> SnippetList;
140         ///
141         SnippetList preamble_snippets_;
142         /// The available (required) packages
143         typedef std::set<std::string> Packages;
144         ///
145         static Packages packages_;
146         ///
147         typedef std::set<Language const *> LanguageList;
148         /// used languages (only those that are supported by babel)
149         LanguageList UsedLanguages_;
150         ///
151         typedef std::map<std::string, bool> UsedFloats;
152         ///
153         UsedFloats usedFloats_;
154         ///
155         typedef std::map<docstring, std::string> FileMap;
156         ///
157         FileMap IncludedFiles_;
158         /** Buffer of the file being processed.
159          *  This may be a child buffer of the to-be-exported file and
160          *  therefore may not be the buffer that belongs to params_.
161          *  Only needed by InsetInclude::validate().
162          */
163         Buffer const * buffer_;
164         ///
165         BufferParams const & params_;
166         /** Some insets need to know details about the to-be-produced file
167          *  in validate().
168          */
169         OutputParams const & runparams_;
170         ///
171         bool in_float_;
172         ///
173         docstring htmltitle_;
174 };
175
176
177 } // namespace lyx
178
179 #endif