]> git.lyx.org Git - lyx.git/blob - src/LaTeXFeatures.h
minimal effort implementation of:
[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
17 #include "outputparams.h"
18
19 #include <set>
20 #include <list>
21 #include <map>
22 #include <string>
23
24 class Buffer;
25 class BufferParams;
26 class Language;
27
28 /** The packages and commands that a buffer needs. This class
29  *  contains a list<string>.  Each of the LaTeX packages that a buffer needs
30  *  should be added with void require(string const & name).
31  *
32  *  i.e require("amssymb")
33  *
34  *  To add support you should only need to require() the package name as
35  *  packages which don't have special requirements are handled automatically.
36  *  If your new package does need special consideration you'll need to alter
37  *  string const getPackages() const;
38  *  Remember to update the validate function in buffer.C and paragraph.C
39  *  when you do so.
40  */
41 class LaTeXFeatures {
42 public:
43         ///
44         LaTeXFeatures(Buffer const &, BufferParams const &,
45                       OutputParams const &);
46         /// The packages needed by the document
47         std::string const getPackages() const;
48         /// The macros definitions needed by the document
49         std::string const getMacros() const;
50         ///
51         std::string const getBabelOptions() const;
52         /// The definitions needed by the document's textclass
53         std::string const getTClassPreamble() const;
54         /// The sgml definitions needed by the document (docbook)
55         std::string const getLyXSGMLEntities() const;
56         /// The SGML Required to include the files added with includeFile();
57         std::string const getIncludedFiles(std::string const & fname) const;
58         /// Include a file for use with the SGML entities
59         void includeFile(std::string const & key, std::string const & name);
60         /// The float definitions.
61         void getFloatDefinitions(std::ostream & os) const;
62         /// Print requirements to lyxerr
63         void showStruct() const;
64         ///
65         void addExternalPreamble(std::string const &);
66         /// Provide a string name-space to the requirements
67         void require(std::string const & name);
68         /// Which of the required packages are installed?
69         static void getAvailable();
70         /// Is the package required?
71         bool isRequired(std::string const & name) const;
72         /// Is the (required) package available?
73         bool isAvailable(std::string const & name) const;
74         ///
75         void useFloat(std::string const & name);
76         ///
77         void useLanguage(Language const *);
78         ///
79         bool hasLanguages() const;
80         ///
81         std::string getLanguages() const;
82         ///
83         std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
84         ///
85         void useLayout(std::string const & lyt);
86         ///
87         Buffer const & buffer() const;
88         ///
89         void setBuffer(Buffer const &);
90         ///
91         BufferParams const & bufferParams() const;
92         /// the return value is dependent upon both LyXRC and LaTeXFeatures.
93         bool useBabel() const;
94         /// Runparams that will be used for exporting this file.
95         OutputParams const & runparams() const { return runparams_; }
96
97 private:
98         std::list<std::string> usedLayouts_;
99
100         /// Static preamble bits from the external material insets
101         typedef std::list<std::string> FeaturesList;
102         ///
103         FeaturesList features_;
104         ///
105         FeaturesList preamble_snippets_;
106         /// The available (required) packages
107         typedef std::list<std::string> PackagesList;
108         ///
109         static PackagesList packages_;
110         ///
111         typedef std::set<Language const *> LanguageList;
112         ///
113         LanguageList UsedLanguages_;
114         ///
115         typedef std::set<std::string> UsedFloats;
116         ///
117         UsedFloats usedFloats_;
118         ///
119         typedef std::map<std::string , std::string> FileMap;
120         ///
121         FileMap IncludedFiles_;
122         /** Buffer of the file being processed.
123          *  This may be a child buffer of the to-be-exported file and
124          *  therefore may not be the buffer that belongs to params_.
125          *  Only needed by InsetInclude::validate().
126          */
127         Buffer const * buffer_;
128         ///
129         BufferParams const & params_;
130         /** Some insets need to know details about the to-be-produced file
131          *  in validate().
132          */
133         OutputParams const & runparams_;
134 };
135
136 #endif