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