]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/context.h
Remove space at end of line, when superfluous.
[lyx.git] / src / tex2lyx / context.h
1 // -*- C++ -*-
2 /**
3  * \file context.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CONTEXT_H
13 #define CONTEXT_H
14
15 #include "lyxtextclass.h"
16
17
18 /*!
19  * Small helper struct that holds font properties.
20  * The names are in LyX language, not LaTeX.
21  * We don't use LyXFont, because it pulls in a lot of dependencies and has
22  * more strings than needed (e.g. font family error1 etc.).
23  * If more font related stuff is needed, it might be good to change to
24  * LyXFont.
25  */
26 struct Font {
27         Font()
28         {
29                 init();
30         }
31         void init()
32         {
33                 size = "normal";
34                 family = "default";
35                 series = "default";
36                 shape = "default";
37         }
38         std::string size;
39         std::string family;
40         std::string series;
41         std::string shape;
42 };
43
44
45 // A helper struct
46 struct Context {
47         Context(bool need_layout_,
48                 LyXTextClass const & textclass_,
49                 LyXLayout_ptr layout_ = LyXLayout_ptr(),
50                 LyXLayout_ptr parent_layout_= LyXLayout_ptr(),
51                 Font font_ = Font());
52
53         // Output a \begin_layout is requested
54         void check_layout(std::ostream & os);
55
56         // Output a \end_layout if needed
57         void check_end_layout(std::ostream & os);
58
59         // Output a \begin_deeper if needed
60         void check_deeper(std::ostream & os);
61
62         // Output a \end_deeper if needed
63         void check_end_deeper(std::ostream & os);
64
65         // dump content on stream (for debugging purpose), with
66         // description \c desc.
67         void dump(std::ostream &, std::string const & desc = "context") const;
68
69         /// Are we just beginning a new paragraph?
70         bool atParagraphStart() const { return need_layout; }
71
72         /// Begin an item in a list environment
73         void set_item();
74
75         /// Start a new paragraph
76         void new_paragraph(std::ostream & os);
77
78         /// Add extra stuff if not already there
79         void add_extra_stuff(std::string const &);
80
81         // Do we need to output some \begin_layout command before the
82         // next characters?
83         bool need_layout;
84         // Do we need to output some \end_layout command
85         bool need_end_layout;
86         // We may need to add something after this \begin_layout command
87         std::string extra_stuff;
88         // If there has been an \begin_deeper, we'll need a matching
89         // \end_deeper
90         bool need_end_deeper;
91         // If we are in an itemize-like environment, we need an \item
92         // for each paragraph, otherwise this has to be a deeper
93         // paragraph.
94         bool has_item;
95         // we are handling a standard paragraph in an itemize-like
96         // environment
97         bool deeper_paragraph;
98
99         // The textclass of the document. Could actually be a global variable
100         LyXTextClass const & textclass;
101         // The layout of the current paragraph
102         LyXLayout_ptr layout;
103         // The layout of the outer paragraph (for environment layouts)
104         LyXLayout_ptr parent_layout;
105         /// font attributes of this context
106         Font font;
107 };
108
109
110 #endif