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\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;
97 if (!extra_stuff.empty()) {
106 void Context::check_end_layout(ostream & os)
108 if (need_end_layout) {
110 need_end_layout = false;
115 void Context::check_deeper(ostream & os)
117 if (parent_layout->isEnvironment()) {
118 if (need_end_deeper) {
119 // no need to have \end_deeper \begin_deeper
120 need_end_deeper = false;
123 need_end_deeper = true;
126 check_end_deeper(os);
130 void Context::check_end_deeper(ostream & os)
132 if (need_end_deeper) {
134 need_end_deeper = false;
136 if (deeper_paragraph) {
138 deeper_paragraph = false;
143 void Context::dump(ostream & os, string const & desc) const
145 os << "\n" << desc <<" [";
147 os << "need_layout ";
149 os << "need_end_layout ";
150 if (!extra_stuff.empty())
151 os << "extrastuff=[" << extra_stuff << "] ";
152 os << "layout=" << layout->name();
153 os << " parent_layout=" << parent_layout->name() << "]" << endl;