]> git.lyx.org Git - lyx.git/blob - src/insets/InsetEnvironment.cpp
header cleanup.
[lyx.git] / src / insets / InsetEnvironment.cpp
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.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetEnvironment.h"
14
15 #include "BufferParams.h"
16 #include "gettext.h"
17 #include "OutputParams.h"
18 #include "output_latex.h"
19 #include "TexRow.h"
20
21
22 namespace lyx {
23
24 using std::string;
25 using std::auto_ptr;
26 using std::ostream;
27
28
29 InsetEnvironment::InsetEnvironment
30                 (BufferParams const & bp, string const & name)
31         : InsetText(bp), layout_(bp.getTextClass()[name]), name_(from_utf8(name))
32 {
33         setAutoBreakRows(true);
34         setDrawFrame(true);
35 }
36
37
38 InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
39         : InsetText(in), layout_(in.layout_)
40 {}
41
42
43 auto_ptr<Inset> InsetEnvironment::doClone() const
44 {
45         return auto_ptr<Inset>(new InsetEnvironment(*this));
46 }
47
48
49 void InsetEnvironment::write(Buffer const & buf, ostream & os) const
50 {
51         os << "Environment " << to_utf8(name()) << "\n";
52         InsetText::write(buf, os);
53 }
54
55
56 void InsetEnvironment::read(Buffer const & buf, Lexer & lex)
57 {
58         InsetText::read(buf, lex);
59 }
60
61
62 docstring const InsetEnvironment::editMessage() const
63 {
64         return _("Opened Environment Inset: ") + name();
65 }
66
67
68 int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
69                             OutputParams const & runparams) const
70 {
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();
79 }
80
81
82 int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os,
83                                 OutputParams const & runparams) const
84 {
85         os << '[' << to_utf8(name()) << ":\n";
86         InsetText::plaintext(buf, os, runparams);
87         os << "\n]";
88
89         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
90 }
91
92
93 Layout_ptr const & InsetEnvironment::layout() const
94 {
95         return layout_;
96 }
97
98
99 } // namespace lyx