]> git.lyx.org Git - lyx.git/blob - src/insets/InsetEnvironment.cpp
remove duplicated code (is already in constructor)
[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 "Buffer.h"
16 #include "BufferParams.h"
17 #include "Layout.h"
18 #include "OutputParams.h"
19 #include "output_latex.h"
20 #include "TexRow.h"
21 #include "TextClass.h"
22
23 #include "support/gettext.h"
24
25 using namespace std;
26
27 namespace lyx {
28
29
30 InsetEnvironment::InsetEnvironment(Buffer const & buf, docstring const & name)
31         : InsetText(buf), layout_(buf.params().documentClass()[name]), name_(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 void InsetEnvironment::write(ostream & os) const
44 {
45         os << "Environment " << to_utf8(name()) << "\n";
46         InsetText::write(os);
47 }
48
49
50 void InsetEnvironment::read(Lexer & lex)
51 {
52         InsetText::read(lex);
53 }
54
55
56 docstring InsetEnvironment::editMessage() const
57 {
58         return _("Opened Environment Inset: ") + name();
59 }
60
61
62 int InsetEnvironment::latex(odocstream & os,
63                             OutputParams const & runparams) const
64 {
65         // FIXME UNICODE
66         os << from_utf8(layout_->latexheader);
67         TexRow texrow;
68         latexParagraphs(buffer(), text_, os, texrow, runparams,
69                         layout_->latexparagraph);
70         // FIXME UNICODE
71         os << from_utf8(layout_->latexfooter);
72         return texrow.rows();
73 }
74
75
76 int InsetEnvironment::plaintext(odocstream & os,
77                                 OutputParams const & runparams) const
78 {
79         os << '[' << to_utf8(name()) << ":\n";
80         InsetText::plaintext(os, runparams);
81         os << "\n]";
82
83         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
84 }
85
86
87 LayoutPtr const & InsetEnvironment::layout() const
88 {
89         return layout_;
90 }
91
92
93 } // namespace lyx