]> git.lyx.org Git - lyx.git/blob - src/insets/InsetEnvironment.cpp
01015f74f10c181445e649cd0d9d2f47d5e166e1
[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 "Paragraph.h"
18 #include "OutputParams.h"
19 #include "output_latex.h"
20 #include "TexRow.h"
21
22
23 namespace lyx {
24
25 using std::string;
26 using std::auto_ptr;
27 using std::ostream;
28
29
30 InsetEnvironment::InsetEnvironment
31                 (BufferParams const & bp, string const & name)
32         : InsetText(bp), layout_(bp.getLyXTextClass()[name])
33 {
34         setInsetName(from_utf8(name));
35         setAutoBreakRows(true);
36         setDrawFrame(true);
37 }
38
39
40 InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
41         : InsetText(in), layout_(in.layout_)
42 {}
43
44
45 auto_ptr<InsetBase> InsetEnvironment::doClone() const
46 {
47         return auto_ptr<InsetBase>(new InsetEnvironment(*this));
48 }
49
50
51 void InsetEnvironment::write(Buffer const & buf, ostream & os) const
52 {
53         os << "Environment " << to_utf8(getInsetName()) << "\n";
54         InsetText::write(buf, os);
55 }
56
57
58 void InsetEnvironment::read(Buffer const & buf, Lexer & lex)
59 {
60         InsetText::read(buf, lex);
61 }
62
63
64 docstring const InsetEnvironment::editMessage() const
65 {
66         return _("Opened Environment Inset: ") + getInsetName();
67 }
68
69
70 int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
71                             OutputParams const & runparams) const
72 {
73         // FIXME UNICODE
74         os << from_utf8(layout_->latexheader);
75         TexRow texrow;
76         latexParagraphs(buf, paragraphs(), os, texrow, runparams,
77                         layout_->latexparagraph);
78         // FIXME UNICODE
79         os << from_utf8(layout_->latexfooter);
80         return texrow.rows();
81 }
82
83
84 int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os,
85                                 OutputParams const & runparams) const
86 {
87         os << '[' << to_utf8(getInsetName()) << ":\n";
88         InsetText::plaintext(buf, os, runparams);
89         os << "\n]";
90
91         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
92 }
93
94
95 LyXLayout_ptr const & InsetEnvironment::layout() const
96 {
97         return layout_;
98 }
99
100
101 } // namespace lyx