]> git.lyx.org Git - lyx.git/blob - src/LaTeXFeatures.h
Rename a couple routines in preparation for more.
[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 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         /// 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;
74         ///
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
88            textclass.
89         */
90         bool mustProvide(std::string const & name) const;
91         ///
92         void useFloat(std::string const & name, bool subfloat = false);
93         ///
94         void useLanguage(Language const *);
95         ///
96         bool hasLanguages() const;
97         ///
98         std::string getLanguages() const;
99         ///
100         std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
101         ///
102         void useLayout(docstring const & lyt);
103         ///
104         void useInsetLayout(InsetLayout const & lay);
105         ///
106         Buffer const & buffer() const;
107         ///
108         void setBuffer(Buffer const &);
109         ///
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_; }
119
120 private:
121         ///
122         std::list<docstring> usedLayouts_;
123         ///
124         std::list<docstring> usedInsetLayouts_;
125         /// The features that are needed by the document
126         typedef std::set<std::string> Features;
127         ///
128         Features features_;
129         /// Static preamble bits from the external material insets
130         typedef std::list<std::string> SnippetList;
131         ///
132         SnippetList preamble_snippets_;
133         /// The available (required) packages
134         typedef std::set<std::string> Packages;
135         ///
136         static Packages packages_;
137         ///
138         typedef std::set<Language const *> LanguageList;
139         /// used languages (only those that are supported by babel)
140         LanguageList UsedLanguages_;
141         ///
142         typedef std::map<std::string, bool> UsedFloats;
143         ///
144         UsedFloats usedFloats_;
145         ///
146         typedef std::map<docstring, std::string> FileMap;
147         ///
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().
153          */
154         Buffer const * buffer_;
155         ///
156         BufferParams const & params_;
157         /** Some insets need to know details about the to-be-produced file
158          *  in validate().
159          */
160         OutputParams const & runparams_;
161         ///
162         bool in_float_;
163 };
164
165
166 } // namespace lyx
167
168 #endif