]> git.lyx.org Git - lyx.git/blob - src/LaTeXFeatures.h
infrastructure for 'graceful asserts'
[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 #include <string>
23
24
25 namespace lyx {
26
27 class Buffer;
28 class BufferParams;
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 packages needed by the document
50         std::string const getPackages() const;
51         /// The macros definitions needed by the document
52         std::string const getMacros() const;
53         ///
54         std::string const getBabelOptions() const;
55         /// The definitions needed by the document's textclass
56         docstring const getTClassPreamble() const;
57         /// The sgml definitions needed by the document (docbook)
58         docstring const getLyXSGMLEntities() const;
59         /// The SGML Required to include the files added with includeFile();
60         docstring const getIncludedFiles(std::string const & fname) const;
61         /// Include a file for use with the SGML entities
62         void includeFile(docstring const & key, std::string const & name);
63         /// The float definitions.
64         void getFloatDefinitions(std::ostream & os) const;
65         /// Print requirements to lyxerr
66         void showStruct() const;
67         ///
68         void addPreambleSnippet(std::string const &);
69         /// Add a feature name requirements
70         void require(std::string const & name);
71         /// Add a set of feature names requirements
72         void require(std::set<std::string> const & names);
73         /// Which of the required packages are installed?
74         static void getAvailable();
75         /// Is the (required) package available?
76         static bool isAvailable(std::string const & name);
77         /// Has the package been required?
78         bool isRequired(std::string const & name) const;
79         /* Is it necessary to load the package? This is true if
80            isRequired is true and the feature is not provided by the
81            textclass.
82         */
83         bool mustProvide(std::string const & name) const;
84         ///
85         void useFloat(std::string const & name, bool subfloat = false);
86         ///
87         void useLanguage(Language const *);
88         ///
89         bool hasLanguages() const;
90         ///
91         std::string getLanguages() const;
92         ///
93         std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
94         ///
95         void useLayout(docstring const & lyt);
96         ///
97         Buffer const & buffer() const;
98         ///
99         void setBuffer(Buffer const &);
100         ///
101         BufferParams const & bufferParams() const;
102         /// the return value is dependent upon both LyXRC and LaTeXFeatures.
103         bool useBabel() const;
104         /// Runparams that will be used for exporting this file.
105         OutputParams const & runparams() const { return runparams_; }
106
107 private:
108         std::list<docstring> usedLayouts_;
109
110         /// The features that are needed by the document
111         typedef std::set<std::string> Features;
112         ///
113         Features features_;
114         /// Static preamble bits from the external material insets
115         typedef std::list<std::string> SnippetList;
116         ///
117         SnippetList preamble_snippets_;
118         /// The available (required) packages
119         typedef std::set<std::string> Packages;
120         ///
121         static Packages packages_;
122         ///
123         typedef std::set<Language const *> LanguageList;
124         /// used languages (only those that are supported by babel)
125         LanguageList UsedLanguages_;
126         ///
127         typedef std::map<std::string, bool> UsedFloats;
128         ///
129         UsedFloats usedFloats_;
130         ///
131         typedef std::map<docstring, std::string> FileMap;
132         ///
133         FileMap IncludedFiles_;
134         /** Buffer of the file being processed.
135          *  This may be a child buffer of the to-be-exported file and
136          *  therefore may not be the buffer that belongs to params_.
137          *  Only needed by InsetInclude::validate().
138          */
139         Buffer const * buffer_;
140         ///
141         BufferParams const & params_;
142         /** Some insets need to know details about the to-be-produced file
143          *  in validate().
144          */
145         OutputParams const & runparams_;
146 };
147
148
149 } // namespace lyx
150
151 #endif