]> git.lyx.org Git - lyx.git/blob - src/insets/InsetEnvironment.cpp
* Only enter inset which return true on isActive(). This is the behavior in the curso...
[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.getTextClass()[name]), name_(from_utf8(name))
33 {
34         setAutoBreakRows(true);
35         setDrawFrame(true);
36 }
37
38
39 InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
40         : InsetText(in), layout_(in.layout_)
41 {}
42
43
44 auto_ptr<Inset> InsetEnvironment::doClone() const
45 {
46         return auto_ptr<Inset>(new InsetEnvironment(*this));
47 }
48
49
50 void InsetEnvironment::write(Buffer const & buf, ostream & os) const
51 {
52         os << "Environment " << to_utf8(name()) << "\n";
53         InsetText::write(buf, os);
54 }
55
56
57 void InsetEnvironment::read(Buffer const & buf, Lexer & lex)
58 {
59         InsetText::read(buf, lex);
60 }
61
62
63 docstring const InsetEnvironment::editMessage() const
64 {
65         return _("Opened Environment Inset: ") + name();
66 }
67
68
69 int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
70                             OutputParams const & runparams) const
71 {
72         // FIXME UNICODE
73         os << from_utf8(layout_->latexheader);
74         TexRow texrow;
75         latexParagraphs(buf, paragraphs(), os, texrow, runparams,
76                         layout_->latexparagraph);
77         // FIXME UNICODE
78         os << from_utf8(layout_->latexfooter);
79         return texrow.rows();
80 }
81
82
83 int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os,
84                                 OutputParams const & runparams) const
85 {
86         os << '[' << to_utf8(name()) << ":\n";
87         InsetText::plaintext(buf, os, runparams);
88         os << "\n]";
89
90         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
91 }
92
93
94 Layout_ptr const & InsetEnvironment::layout() const
95 {
96         return layout_;
97 }
98
99
100 } // namespace lyx