]> git.lyx.org Git - features.git/blob - src/LaTeXFeatures.h
e076e996e361c00dc5cbc9194be677677f09abaa
[features.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 #include <string>
23
24
25 namespace lyx {
26
27 class Buffer;
28 class BufferParams;
29 class InsetLayout;
30 class Language;
31
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).
35  *
36  *  i.e require("amssymb")
37  *
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
43  *  when you do so.
44  */
45 class LaTeXFeatures {
46 public:
47         ///
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;
56         ///
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;
62         ///
63         docstring const getTClassHTMLStyles() const;
64         ///
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;
76         ///
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
90            textclass.
91         */
92         bool mustProvide(std::string const & name) const;
93         ///
94         void useFloat(std::string const & name, bool subfloat = false);
95         ///
96         void useLanguage(Language const *);
97         ///
98         bool hasLanguages() const;
99         ///
100         std::string getLanguages() const;
101         ///
102         std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
103         ///
104         void useLayout(docstring const & lyt);
105         ///
106         void useInsetLayout(InsetLayout const & lay);
107         ///
108         Buffer const & buffer() const;
109         ///
110         void setBuffer(Buffer const &);
111         ///
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_; }
121
122 private:
123         ///
124         std::list<docstring> usedLayouts_;
125         ///
126         std::list<docstring> usedInsetLayouts_;
127         /// The features that are needed by the document
128         typedef std::set<std::string> Features;
129         ///
130         Features features_;
131         /// Static preamble bits from the external material insets
132         typedef std::list<std::string> SnippetList;
133         ///
134         SnippetList preamble_snippets_;
135         /// The available (required) packages
136         typedef std::set<std::string> Packages;
137         ///
138         static Packages packages_;
139         ///
140         typedef std::set<Language const *> LanguageList;
141         /// used languages (only those that are supported by babel)
142         LanguageList UsedLanguages_;
143         ///
144         typedef std::map<std::string, bool> UsedFloats;
145         ///
146         UsedFloats usedFloats_;
147         ///
148         typedef std::map<docstring, std::string> FileMap;
149         ///
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().
155          */
156         Buffer const * buffer_;
157         ///
158         BufferParams const & params_;
159         /** Some insets need to know details about the to-be-produced file
160          *  in validate().
161          */
162         OutputParams const & runparams_;
163         ///
164         bool in_float_;
165 };
166
167
168 } // namespace lyx
169
170 #endif