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