* qt_helpers.cpp:
[lyx.git] / src / LaTeXFeatures.h
blobbc666ff34be99627867d3e314c9d015287c739cf
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.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
13 #ifndef LATEXFEATURES_H
14 #define LATEXFEATURES_H
16 #include "OutputParams.h"
17 #include "support/docstring.h"
19 #include <set>
20 #include <list>
21 #include <map>
24 namespace lyx {
26 class Buffer;
27 class BufferParams;
28 class InsetLayout;
29 class Language;
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).
35 * i.e require("amssymb")
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.
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 ///
56 std::string const getBabelOptions() const;
57 /// The definitions needed by the document's textclass
58 docstring const getTClassPreamble() const;
59 /// The language dependent definitions needed by the document's textclass
60 docstring const getTClassI18nPreamble(bool use_babel) const;
61 ///
62 docstring const getTClassHTMLStyles() const;
63 ///
64 docstring const getTClassHTMLPreamble() const;
65 /// The sgml definitions needed by the document (docbook)
66 docstring const getLyXSGMLEntities() const;
67 /// The SGML Required to include the files added with includeFile();
68 docstring const getIncludedFiles(std::string const & fname) const;
69 /// Include a file for use with the SGML entities
70 void includeFile(docstring const & key, std::string const & name);
71 /// The float definitions.
72 void getFloatDefinitions(odocstream & os) const;
73 /// Print requirements to lyxerr
74 void showStruct() const;
75 ///
76 void addPreambleSnippet(std::string const &);
77 /// Add a feature name requirements
78 void require(std::string const & name);
79 /// Add a set of feature names requirements
80 void require(std::set<std::string> const & names);
81 /// Which of the required packages are installed?
82 static void getAvailable();
83 /// Is the (required) package available?
84 static bool isAvailable(std::string const & name);
85 /// Has the package been required?
86 bool isRequired(std::string const & name) const;
87 /* Is it necessary to load the package? This is true if
88 isRequired is true and the feature is not provided by the
89 textclass.
91 bool mustProvide(std::string const & name) const;
92 ///
93 void useFloat(std::string const & name, bool subfloat = false);
94 ///
95 void useLanguage(Language const *);
96 ///
97 bool hasLanguages() const;
98 ///
99 std::string getLanguages() const;
101 std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
103 void useLayout(docstring const & lyt);
105 void useInsetLayout(InsetLayout const & lay);
107 Buffer const & buffer() const;
109 void setBuffer(Buffer const &);
111 BufferParams const & bufferParams() const;
112 /// the return value is dependent upon both LyXRC and LaTeXFeatures.
113 bool useBabel() const;
114 /// are we in a float?
115 bool inFloat() const { return in_float_; }
116 /// are we in a float?
117 void inFloat(bool const b) { in_float_ = b; }
118 /// Runparams that will be used for exporting this file.
119 OutputParams const & runparams() const { return runparams_; }
121 private:
123 std::list<docstring> usedLayouts_;
125 std::list<docstring> usedInsetLayouts_;
126 /// The features that are needed by the document
127 typedef std::set<std::string> Features;
129 Features features_;
130 /// Static preamble bits from the external material insets
131 typedef std::list<std::string> SnippetList;
133 SnippetList preamble_snippets_;
134 /// The available (required) packages
135 typedef std::set<std::string> Packages;
137 static Packages packages_;
139 typedef std::set<Language const *> LanguageList;
140 /// used languages (only those that are supported by babel)
141 LanguageList UsedLanguages_;
143 typedef std::map<std::string, bool> UsedFloats;
145 UsedFloats usedFloats_;
147 typedef std::map<docstring, std::string> FileMap;
149 FileMap IncludedFiles_;
150 /** Buffer of the file being processed.
151 * This may be a child buffer of the to-be-exported file and
152 * therefore may not be the buffer that belongs to params_.
153 * Only needed by InsetInclude::validate().
155 Buffer const * buffer_;
157 BufferParams const & params_;
158 /** Some insets need to know details about the to-be-produced file
159 * in validate().
161 OutputParams const & runparams_;
163 bool in_float_;
167 } // namespace lyx
169 #endif