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