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