]> git.lyx.org Git - lyx.git/blob - src/insets/insetenv.C
fix #832
[lyx.git] / src / insets / insetenv.C
1 // -*- C++ -*-
2 /**
3  * \file insetenv.C
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #include "insetenv.h"
15 #include "gettext.h"
16 #include "lyxtextclass.h"
17 #include "lyxlayout.h"
18 #include "bufferparams.h"
19 #include "support/LOstream.h"
20 #include "debug.h"
21
22
23 using std::ostream;
24 using std::endl;
25
26
27 InsetEnvironment::InsetEnvironment
28                 (BufferParams const & bp, string const & name)
29         : InsetText(bp)
30 {
31         //setLabel(name);
32         setInsetName(name);
33         autoBreakRows = true;
34         drawFrame_ = ALWAYS;
35         // needs more stuff in lyxlayout. coming in later patches.
36         //LyXTextClass const & tc = bp.getLyXTextClass();
37         //LyXLayout_ptr const & layout = tc.getEnv(name);
38         //header_ = layout->latexheader;
39         //footer_ = layout->latexfooter;
40         header_ = "\\begin{" + name + "}";
41         footer_ = "\\end{" + name + "}";
42 }
43
44
45 InsetEnvironment::InsetEnvironment(InsetEnvironment const & in, bool same_id)
46         : InsetText(in, same_id), header_(in.header_), footer_(in.footer_)
47 {}
48
49
50 Inset * InsetEnvironment::clone(Buffer const &, bool same_id) const
51 {
52         return new InsetEnvironment(*this, same_id);
53 }
54
55
56 void InsetEnvironment::write(Buffer const * buf, ostream & os) const
57 {
58         os << "Environment " << getInsetName() << "\n";
59         InsetText::write(buf, os);
60 }
61
62
63 void InsetEnvironment::read(Buffer const * buf, LyXLex & lex)
64 {
65         InsetText::read(buf, lex);
66 }
67
68
69 string const InsetEnvironment::editMessage() const
70 {
71         return _("Opened Environment Inset: ") + getInsetName();
72 }
73
74
75 int InsetEnvironment::latex(Buffer const * buf,
76                          ostream & os, bool fragile, bool fp) const
77 {
78         os << header_;
79         int i = InsetText::latex(buf, os, fragile, fp);
80         os << footer_;
81         return i;
82 }