3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jean-Marc Lasgouttes
8 * Full author contact details are available in file CREDITS.
24 void begin_layout(ostream & os, LyXLayout_ptr layout)
26 os << "\n\\begin_layout " << layout->name() << "\n";
30 void end_layout(ostream & os)
32 os << "\n\\end_layout\n";
36 void begin_deeper(ostream & os)
38 os << "\n\\begin_deeper \n";
42 void end_deeper(ostream & os)
44 os << "\n\\end_deeper \n";
49 Context::Context(bool need_layout_,
50 LyXTextClass const & textclass_,
51 LyXLayout_ptr layout_, LyXLayout_ptr parent_layout_)
52 : need_layout(need_layout_),
53 need_end_layout(false), need_end_deeper(false),
54 has_item(false), deeper_paragraph(false),
55 textclass(textclass_),
56 layout(layout_), parent_layout(parent_layout_)
59 layout = textclass.defaultLayout();
60 if (!parent_layout.get())
61 parent_layout = textclass.defaultLayout();
65 void Context::check_layout(ostream & os)
70 // are we in a list-like environment?
71 if (layout->isEnvironment()
72 && layout->latextype != LATEX_ENVIRONMENT) {
74 if (deeper_paragraph) {
76 deeper_paragraph = false;
78 begin_layout(os, layout);
81 need_end_layout = true;
83 // a standard paragraph in an
84 // enumeration. We have to recognize
85 // that this may require a begin_deeper.
86 if (!deeper_paragraph)
88 begin_layout(os, textclass.defaultLayout());
90 need_end_layout = true;
91 deeper_paragraph = true;
94 begin_layout(os, layout);
96 need_end_layout = true;
98 if (!extra_stuff.empty()) {
107 void Context::check_end_layout(ostream & os)
109 if (need_end_layout) {
111 need_end_layout = false;
116 void Context::check_deeper(ostream & os)
118 if (parent_layout->isEnvironment()) {
119 if (need_end_deeper) {
120 // no need to have \end_deeper \begin_deeper
121 need_end_deeper = false;
124 need_end_deeper = true;
127 check_end_deeper(os);
131 void Context::check_end_deeper(ostream & os)
133 if (need_end_deeper) {
135 need_end_deeper = false;
137 if (deeper_paragraph) {
139 deeper_paragraph = false;
144 void Context::set_item()
151 void Context::new_paragraph(ostream & os)
153 check_end_layout(os);
158 void Context::dump(ostream & os, string const & desc) const
160 os << "\n" << desc <<" [";
162 os << "need_layout ";
164 os << "need_end_layout ";
166 os << "need_end_deeper ";
169 if (deeper_paragraph)
170 os << "deeper_paragraph ";
171 if (!extra_stuff.empty())
172 os << "extrastuff=[" << extra_stuff << "] ";
173 os << "layout=" << layout->name();
174 os << " parent_layout=" << parent_layout->name() << "]" << endl;