LyX 1.5.0 is released
[lyx.git] / src / insets / InsetEnvironment.cpp
blobf665e86b342a2676c35a3713724c000ddf60b1d3
1 /**
2 * \file InsetEnvironment.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author André Pönitz
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "InsetEnvironment.h"
15 #include "BufferParams.h"
16 #include "gettext.h"
17 #include "OutputParams.h"
18 #include "output_latex.h"
19 #include "TexRow.h"
22 namespace lyx {
24 using std::string;
25 using std::auto_ptr;
26 using std::ostream;
29 InsetEnvironment::InsetEnvironment
30 (BufferParams const & bp, docstring const & name)
31 : InsetText(bp), layout_(bp.getTextClass()[name]), name_(name)
33 setAutoBreakRows(true);
34 setDrawFrame(true);
38 InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
39 : InsetText(in), layout_(in.layout_)
43 auto_ptr<Inset> InsetEnvironment::doClone() const
45 return auto_ptr<Inset>(new InsetEnvironment(*this));
49 void InsetEnvironment::write(Buffer const & buf, ostream & os) const
51 os << "Environment " << to_utf8(name()) << "\n";
52 InsetText::write(buf, os);
56 void InsetEnvironment::read(Buffer const & buf, Lexer & lex)
58 InsetText::read(buf, lex);
62 docstring const InsetEnvironment::editMessage() const
64 return _("Opened Environment Inset: ") + name();
68 int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
69 OutputParams const & runparams) const
71 // FIXME UNICODE
72 os << from_utf8(layout_->latexheader);
73 TexRow texrow;
74 latexParagraphs(buf, paragraphs(), os, texrow, runparams,
75 layout_->latexparagraph);
76 // FIXME UNICODE
77 os << from_utf8(layout_->latexfooter);
78 return texrow.rows();
82 int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os,
83 OutputParams const & runparams) const
85 os << '[' << to_utf8(name()) << ":\n";
86 InsetText::plaintext(buf, os, runparams);
87 os << "\n]";
89 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
93 Layout_ptr const & InsetEnvironment::layout() const
95 return layout_;
99 } // namespace lyx