4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Jean-Marc Lasgouttes
9 * Full author contact details are available in file CREDITS.
15 #include "lyxtextclass.h"
21 * Small helper struct that holds font properties.
22 * The names are in LyX language, not LaTeX.
23 * We don't use LyXFont, because it pulls in a lot of dependencies and has
24 * more strings than needed (e.g. font family error1 etc.).
25 * If more font related stuff is needed, it might be good to change to
48 bool operator==(Font const &, Font const &);
51 inline bool operator!=(Font const & f1, Font const & f2)
53 return !operator==(f1, f2);
57 /// Output changed font parameters if \p oldfont and \p newfont differ
58 void output_font_change(std::ostream & os, Font const & oldfont,
59 Font const & newfont);
65 * Every bit of text has a corresponding context.
66 * Usage: Parsing begins with a global context. A new context is opened for
67 * every new LaTeX group, e.g. at the beginning of a new environment.
68 * The old context is used again after the group is closed.
70 * Since not all paragraph parameters in LyX have the same scoping as their
71 * LaTeX counterpart we may have to transfer context properties (e. g. the
72 * font) from and to the parent context.
76 Context(bool need_layout_,
77 LyXTextClass const & textclass_,
78 LyXLayout_ptr layout_ = LyXLayout_ptr(),
79 LyXLayout_ptr parent_layout_= LyXLayout_ptr(),
83 /// Output a \\begin_layout if requested
84 void check_layout(std::ostream & os);
86 /// Output a \\end_layout if needed
87 void check_end_layout(std::ostream & os);
89 /// Output a \\begin_deeper if needed
90 void check_deeper(std::ostream & os);
92 /// Output a \\end_deeper if needed
93 void check_end_deeper(std::ostream & os);
95 /// dump content on stream (for debugging purpose), with
96 /// description \c desc.
97 void dump(std::ostream &, std::string const & desc = "context") const;
99 /// Are we just beginning a new paragraph?
100 bool atParagraphStart() const { return need_layout; }
102 /// Begin an item in a list environment
105 /// Start a new paragraph
106 void new_paragraph(std::ostream & os);
108 /// Add extra stuff if not already there
109 void add_extra_stuff(std::string const &);
111 /// Do we need to output some \\begin_layout command before the
114 /// Do we need to output some \\end_layout command
115 bool need_end_layout;
116 /// We may need to add something after this \\begin_layout command
117 std::string extra_stuff;
118 /// If there has been an \\begin_deeper, we'll need a matching
120 bool need_end_deeper;
121 /// If we are in an itemize-like environment, we need an \item
122 /// for each paragraph, otherwise this has to be a deeper
125 /// we are handling a standard paragraph in an itemize-like
127 bool deeper_paragraph;
129 * Inside of unknown environments we may not allow font and layout
131 * Otherwise things like
132 * \\large\\begin{foo}\\huge bar\\end{foo}
135 bool new_layout_allowed;
136 /// Did we output anything yet in any context?
139 /// The textclass of the document. Could actually be a global variable
140 LyXTextClass const & textclass;
141 /// The layout of the current paragraph
142 LyXLayout_ptr layout;
143 /// The layout of the outer paragraph (for environment layouts)
144 LyXLayout_ptr parent_layout;
145 /// font attributes of this context
147 /// font attributes of normal text
148 static Font normalfont;