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