]> git.lyx.org Git - lyx.git/blob - src/insets/insetenv.C
the clone auto_ptr patch
[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 "paragraph_funcs.h"
18 #include "lyxlayout.h"
19 #include "bufferparams.h"
20 #include "support/LOstream.h"
21 #include "debug.h"
22
23
24 using std::ostream;
25 using std::endl;
26 using std::auto_ptr;
27
28
29 InsetEnvironment::InsetEnvironment
30                 (BufferParams const & bp, string const & name)
31         : InsetText(bp), layout_(bp.getLyXTextClass()[name])
32 {
33         setInsetName(name);
34         autoBreakRows = true;
35         drawFrame_ = ALWAYS;
36 }
37
38
39 InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
40         : InsetText(in), layout_(in.layout_)
41 {}
42
43
44 auto_ptr<InsetBase> InsetEnvironment::clone() const
45 {
46         return auto_ptr<InsetBase>(new InsetEnvironment(*this));
47 }
48
49
50 void InsetEnvironment::write(Buffer const * buf, ostream & os) const
51 {
52         os << "Environment " << getInsetName() << "\n";
53         InsetText::write(buf, os);
54 }
55
56
57 void InsetEnvironment::read(Buffer const * buf, LyXLex & lex)
58 {
59         InsetText::read(buf, lex);
60 }
61
62
63 string const InsetEnvironment::editMessage() const
64 {
65         return _("Opened Environment Inset: ") + getInsetName();
66 }
67
68
69 int InsetEnvironment::latex(Buffer const * buf, ostream & os,
70                             LatexRunParams const & runparams) const
71 {
72         os << layout_->latexheader;
73         TexRow texrow;
74         latexParagraphs(buf, paragraphs, os, texrow, runparams,
75                         layout_->latexparagraph);
76         os << layout_->latexfooter;
77         return texrow.rows();
78 }
79
80
81 LyXLayout_ptr const & InsetEnvironment::layout() const
82 {
83         return layout_;
84 }