]> git.lyx.org Git - lyx.git/blob - src/LaTeXFeatures.h
Simplify the public interface of Buffer::doExport
[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         /// 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;
67         ///
68         docstring const getTClassHTMLStyles() const;
69         ///
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;
81         ///
82         void addPreambleSnippet(std::string const &);
83         ///
84         std::string getPreambleSnippets() const;
85         /// Add a feature name requirements
86         void require(std::string const & name);
87         /// Add a set of feature names requirements
88         void require(std::set<std::string> const & names);
89         /// Which of the required packages are installed?
90         static void getAvailable();
91         /// Is the (required) package available?
92         static bool isAvailable(std::string const & name);
93         /// Has the package been required?
94         bool isRequired(std::string const & name) const;
95         /* Is it necessary to load the package? This is true if
96            isRequired is true and the feature is not provided by the
97            textclass.
98         */
99         bool mustProvide(std::string const & name) const;
100         ///
101         void useFloat(std::string const & name, bool subfloat = false);
102         ///
103         void useLanguage(Language const *);
104         ///
105         bool hasLanguages() const;
106         /// check if all used languages are supported by polyglossia
107         bool hasPolyglossiaLanguages() const;
108         ///
109         std::string getLanguages() const;
110         ///
111         std::map<std::string, std::string> getPolyglossiaLanguages() const;
112         ///
113         std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
114         ///
115         void useLayout(docstring const & lyt);
116         ///
117         void useInsetLayout(InsetLayout const & lay);
118         ///
119         Buffer const & buffer() const;
120         ///
121         void setBuffer(Buffer const &);
122         ///
123         BufferParams const & bufferParams() const;
124         /// the return value is dependent upon both LyXRC and LaTeXFeatures.
125         bool useBabel() const;
126         ///
127         bool usePolyglossia() const;
128         /// are we in a float?
129         bool inFloat() const { return in_float_; }
130         /// are we in a float?
131         void inFloat(bool const b) { in_float_ = b; }
132         /// Runparams that will be used for exporting this file.
133         OutputParams const & runparams() const { return runparams_; }
134         /// Resolve alternatives like "esint|amsmath|wasysym"
135         void resolveAlternatives();
136         ///
137         void setHTMLTitle(docstring const & t) { htmltitle_ = t; }
138         ///
139         docstring const & htmlTitle() const { return htmltitle_; }
140
141 private:
142         ///
143         std::list<docstring> usedLayouts_;
144         ///
145         std::list<docstring> usedInsetLayouts_;
146         /// The features that are needed by the document
147         typedef std::set<std::string> Features;
148         ///
149         Features features_;
150         /// Static preamble bits, from external templates, or anywhere else
151         typedef std::list<std::string> SnippetList;
152         ///
153         SnippetList preamble_snippets_;
154         /// The available (required) packages
155         typedef std::set<std::string> Packages;
156         ///
157         static Packages packages_;
158         ///
159         typedef std::set<Language const *> LanguageList;
160         /// used languages (only those that are supported by babel)
161         LanguageList UsedLanguages_;
162         ///
163         typedef std::map<std::string, bool> UsedFloats;
164         ///
165         UsedFloats usedFloats_;
166         ///
167         typedef std::map<docstring, std::string> FileMap;
168         ///
169         FileMap IncludedFiles_;
170         /** Buffer of the file being processed.
171          *  This may be a child buffer of the to-be-exported file and
172          *  therefore may not be the buffer that belongs to params_.
173          *  Only needed by InsetInclude::validate().
174          */
175         Buffer const * buffer_;
176         ///
177         BufferParams const & params_;
178         /** Some insets need to know details about the to-be-produced file
179          *  in validate().
180          */
181         OutputParams const & runparams_;
182         ///
183         bool in_float_;
184         ///
185         docstring htmltitle_;
186 };
187
188
189 } // namespace lyx
190
191 #endif