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.
24 * Small helper struct that holds font properties.
25 * The names are in LyX language, not LaTeX.
26 * We don't use Font, because it pulls in a lot of dependencies and has
27 * more strings than needed (e.g. font family error1 etc.).
28 * If more font related stuff is needed, it might be good to change to
51 bool operator==(TeXFont const &, TeXFont const &);
54 inline bool operator!=(TeXFont const & f1, TeXFont const & f2)
56 return !operator==(f1, f2);
60 /// Output changed font parameters if \p oldfont and \p newfont differ
61 void output_font_change(std::ostream & os, TeXFont const & oldfont,
62 TeXFont const & newfont);
68 * Every bit of text has a corresponding context.
69 * Usage: Parsing begins with a global context. A new context is opened for
70 * every new LaTeX group, e.g. at the beginning of a new environment.
71 * The old context is used again after the group is closed.
73 * Since not all paragraph parameters in LyX have the same scoping as their
74 * LaTeX counterpart we may have to transfer context properties (e. g. the
75 * font) from and to the parent context.
79 Context(bool need_layout_,
80 TeX2LyXDocClass const & textclass_,
81 LayoutPtr layout_ = LayoutPtr(),
82 LayoutPtr parent_layout_= LayoutPtr(),
83 TeXFont font_ = TeXFont());
86 /// Output a \\begin_layout if requested
87 void check_layout(std::ostream & os);
89 /// Output a \\end_layout if needed
90 void check_end_layout(std::ostream & os);
92 /// Output a \\begin_deeper if needed
93 void check_deeper(std::ostream & os);
95 /// Output a \\end_deeper if needed
96 void check_end_deeper(std::ostream & os);
98 /// dump content on stream (for debugging purpose), with
99 /// description \c desc.
100 void dump(std::ostream &, std::string const & desc = "context") const;
102 /// Are we just beginning a new paragraph?
103 bool atParagraphStart() const { return need_layout; }
105 /// Begin an item in a list environment
108 /// Start a new paragraph
109 void new_paragraph(std::ostream & os);
111 /// Add extra stuff if not already there
112 void add_extra_stuff(std::string const &);
114 /// Do we need to output some \\begin_layout command before the
117 /// Do we need to output some \\end_layout command
118 bool need_end_layout;
119 /// We may need to add something after this \\begin_layout command
120 std::string extra_stuff;
121 /// If there has been an \\begin_deeper, we'll need a matching
123 bool need_end_deeper;
124 /// If we are in an itemize-like environment, we need an \item
125 /// for each paragraph, otherwise this has to be a deeper
128 /// we are handling a standard paragraph in an itemize-like
130 bool deeper_paragraph;
132 * Inside of unknown environments we may not allow font and layout
134 * Otherwise things like
135 * \\large\\begin{foo}\\huge bar\\end{foo}
138 bool new_layout_allowed;
139 /// Did we output anything yet in any context?
142 /// The textclass of the document. Could actually be a global variable
143 TeX2LyXDocClass const & textclass;
144 /// The layout of the current paragraph
146 /// The layout of the outer paragraph (for environment layouts)
147 LayoutPtr parent_layout;
148 /// font attributes of this context
150 /// font attributes of normal text
151 static TeXFont normalfont;