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
20 void begin_layout(ostream & os, LyXLayout_ptr layout)
22 os << "\n\\begin_layout " << layout->name() << "\n\n";
26 void end_layout(ostream & os)
28 os << "\n\\end_layout\n";
32 void begin_deeper(ostream & os)
34 os << "\n\\begin_deeper \n";
38 void end_deeper(ostream & os)
40 os << "\n\\end_deeper \n";
45 Context::Context(bool need_layout_,
46 LyXTextClass const & textclass_,
47 LyXLayout_ptr layout_, LyXLayout_ptr parent_layout_)
48 : need_layout(need_layout_),
49 need_end_layout(false), need_end_deeper(false),
50 has_item(false), deeper_paragraph(false),
51 textclass(textclass_),
52 layout(layout_), parent_layout(parent_layout_)
55 layout = textclass.defaultLayout();
56 if (!parent_layout.get())
57 parent_layout = textclass.defaultLayout();
61 void Context::check_layout(ostream & os)
66 // are we in a list-like environment?
67 if (layout->isEnvironment()
68 && layout->latextype != LATEX_ENVIRONMENT) {
70 if (deeper_paragraph) {
72 deeper_paragraph = false;
74 begin_layout(os, layout);
77 need_end_layout = true;
79 // a standard paragraph in an
80 // enumeration. We have to recognize
81 // that this may require a begin_deeper.
82 if (!deeper_paragraph)
84 begin_layout(os, textclass.defaultLayout());
86 need_end_layout = true;
87 deeper_paragraph = true;
90 begin_layout(os, layout);
92 need_end_layout = true;
93 if (!extra_stuff.empty()) {
102 void Context::check_end_layout(ostream & os)
104 if (need_end_layout) {
106 need_end_layout = false;
111 void Context::check_deeper(ostream & os)
113 if (parent_layout->isEnvironment()) {
114 if (need_end_deeper) {
115 // no need to have \end_deeper \begin_deeper
116 need_end_deeper = false;
119 need_end_deeper = true;
122 check_end_deeper(os);
126 void Context::check_end_deeper(ostream & os)
128 if (need_end_deeper) {
130 need_end_deeper = false;
132 if (deeper_paragraph) {
134 deeper_paragraph = false;
139 void Context::dump(ostream & os, string const & desc) const
141 os << "\n" << desc <<" [";
143 os << "need_layout ";
145 os << "need_end_layout ";
146 if (!extra_stuff.empty())
147 os << "extrastuff=[" << extra_stuff << "] ";
148 os << "layout=" << layout->name();
149 os << " parent_layout=" << parent_layout->name() << "]" << endl;