]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/context.h
fix tex2lyx table column specification parsing
[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 class Font {
27 public:
28         Font()
29         {
30                 init();
31         }
32         void init()
33         {
34                 size = "normal";
35                 family = "default";
36                 series = "default";
37                 shape = "default";
38         }
39         std::string size;
40         std::string family;
41         std::string series;
42         std::string shape;
43 };
44
45
46 // A helper struct
47 class Context {
48 public:
49         Context(bool need_layout_,
50                 LyXTextClass const & textclass_,
51                 LyXLayout_ptr layout_ = LyXLayout_ptr(),
52                 LyXLayout_ptr parent_layout_= LyXLayout_ptr(),
53                 Font font_ = Font());
54
55         // Output a \begin_layout is requested
56         void check_layout(std::ostream & os);
57
58         // Output a \end_layout if needed
59         void check_end_layout(std::ostream & os);
60
61         // Output a \begin_deeper if needed
62         void check_deeper(std::ostream & os);
63
64         // Output a \end_deeper if needed
65         void check_end_deeper(std::ostream & os);
66
67         // dump content on stream (for debugging purpose), with
68         // description \c desc.
69         void dump(std::ostream &, std::string const & desc = "context") const;
70
71         /// Are we just beginning a new paragraph?
72         bool atParagraphStart() const { return need_layout; }
73
74         /// Begin an item in a list environment
75         void set_item();
76
77         /// Start a new paragraph
78         void new_paragraph(std::ostream & os);
79
80         /// Add extra stuff if not already there
81         void add_extra_stuff(std::string const &);
82
83         // Do we need to output some \begin_layout command before the
84         // next characters?
85         bool need_layout;
86         // Do we need to output some \end_layout command
87         bool need_end_layout;
88         // We may need to add something after this \begin_layout command
89         std::string extra_stuff;
90         // If there has been an \begin_deeper, we'll need a matching
91         // \end_deeper
92         bool need_end_deeper;
93         // If we are in an itemize-like environment, we need an \item
94         // for each paragraph, otherwise this has to be a deeper
95         // paragraph.
96         bool has_item;
97         // we are handling a standard paragraph in an itemize-like
98         // environment
99         bool deeper_paragraph;
100
101         // The textclass of the document. Could actually be a global variable
102         LyXTextClass const & textclass;
103         // The layout of the current paragraph
104         LyXLayout_ptr layout;
105         // The layout of the outer paragraph (for environment layouts)
106         LyXLayout_ptr parent_layout;
107         /// font attributes of this context
108         Font font;
109 };
110
111 #endif