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.
22 void begin_layout(ostream & os, LyXLayout_ptr layout)
24 os << "\n\\begin_layout " << layout->name() << "\n\n";
28 void end_layout(ostream & os)
30 os << "\n\\end_layout\n";
34 void begin_deeper(ostream & os)
36 os << "\n\\begin_deeper \n";
40 void end_deeper(ostream & os)
42 os << "\n\\end_deeper \n";
47 Context::Context(bool need_layout_,
48 LyXTextClass const & textclass_,
49 LyXLayout_ptr layout_, LyXLayout_ptr parent_layout_)
50 : need_layout(need_layout_),
51 need_end_layout(false), need_end_deeper(false),
52 has_item(false), deeper_paragraph(false),
53 textclass(textclass_),
54 layout(layout_), parent_layout(parent_layout_)
57 layout = textclass.defaultLayout();
58 if (!parent_layout.get())
59 parent_layout = textclass.defaultLayout();
63 void Context::check_layout(ostream & os)
68 // are we in a list-like environment?
69 if (layout->isEnvironment()
70 && layout->latextype != LATEX_ENVIRONMENT) {
72 if (deeper_paragraph) {
74 deeper_paragraph = false;
76 begin_layout(os, layout);
79 need_end_layout = true;
81 // a standard paragraph in an
82 // enumeration. We have to recognize
83 // that this may require a begin_deeper.
84 if (!deeper_paragraph)
86 begin_layout(os, textclass.defaultLayout());
88 need_end_layout = true;
89 deeper_paragraph = true;
92 begin_layout(os, layout);
94 need_end_layout = true;
95 if (!extra_stuff.empty()) {
104 void Context::check_end_layout(ostream & os)
106 if (need_end_layout) {
108 need_end_layout = false;
113 void Context::check_deeper(ostream & os)
115 if (parent_layout->isEnvironment()) {
116 if (need_end_deeper) {
117 // no need to have \end_deeper \begin_deeper
118 need_end_deeper = false;
121 need_end_deeper = true;
124 check_end_deeper(os);
128 void Context::check_end_deeper(ostream & os)
130 if (need_end_deeper) {
132 need_end_deeper = false;
134 if (deeper_paragraph) {
136 deeper_paragraph = false;
141 void Context::dump(ostream & os, string const & desc) const
143 os << "\n" << desc <<" [";
145 os << "need_layout ";
147 os << "need_end_layout ";
148 if (!extra_stuff.empty())
149 os << "extrastuff=[" << extra_stuff << "] ";
150 os << "layout=" << layout->name();
151 os << " parent_layout=" << parent_layout->name() << "]" << endl;