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