]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetenv.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / insetenv.C
index b17fe08c2ebf07220a6b77c17a5e511b8cb7cd6c..7e6c7ad70f05eac072ba36ee8dba313bc5b6c804 100644 (file)
@@ -14,6 +14,7 @@
 #include "insetenv.h"
 #include "gettext.h"
 #include "lyxtextclass.h"
+#include "paragraph_funcs.h"
 #include "lyxlayout.h"
 #include "bufferparams.h"
 #include "support/LOstream.h"
 
 using std::ostream;
 using std::endl;
+using std::auto_ptr;
 
 
 InsetEnvironment::InsetEnvironment
                (BufferParams const & bp, string const & name)
-       : InsetCollapsable(bp)
+       : InsetText(bp), layout_(bp.getLyXTextClass()[name])
 {
-       setLabel(name);
        setInsetName(name);
-       // needs more stuff in lyxlayout. coming in later patches.
-       //LyXTextClass const & tc = bp.getLyXTextClass();
-       //LyXLayout_ptr const & layout = tc.getEnv(name);
-       //header_ = layout->latexheader;
-       //footer_ = layout->latexfooter;
+       autoBreakRows = true;
+       drawFrame_ = ALWAYS;
 }
 
 
-InsetEnvironment::InsetEnvironment(InsetEnvironment const & in, bool same_id)
-       : InsetCollapsable(in, same_id), header_(in.header_), footer_(in.footer_)
+InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
+       : InsetText(in), layout_(in.layout_)
 {}
 
 
-Inset * InsetEnvironment::clone(Buffer const &, bool same_id) const
+auto_ptr<InsetBase> InsetEnvironment::clone() const
 {
-       return new InsetEnvironment(*this, same_id);
+       return auto_ptr<InsetBase>(new InsetEnvironment(*this));
 }
 
 
 void InsetEnvironment::write(Buffer const * buf, ostream & os) const
 {
-       os << "Environment " << getInsetName() << "\"\n";
-       InsetCollapsable::write(buf, os);
+       os << "Environment " << getInsetName() << "\n";
+       InsetText::write(buf, os);
 }
 
 
 void InsetEnvironment::read(Buffer const * buf, LyXLex & lex)
 {
-       InsetCollapsable::read(buf, lex);
+       InsetText::read(buf, lex);
 }
 
 
@@ -68,11 +66,19 @@ string const InsetEnvironment::editMessage() const
 }
 
 
-int InsetEnvironment::latex(Buffer const * buf,
-                        ostream & os, bool fragile, bool fp) const
+int InsetEnvironment::latex(Buffer const * buf, ostream & os,
+                           LatexRunParams const & runparams) const
 {
-       os << header_;
-       int i = inset.latex(buf, os, fragile, fp);
-       os << footer_;
-       return i;
+       os << layout_->latexheader;
+       TexRow texrow;
+       latexParagraphs(buf, paragraphs, os, texrow, runparams,
+                       layout_->latexparagraph);
+       os << layout_->latexfooter;
+       return texrow.rows();
+}
+
+
+LyXLayout_ptr const & InsetEnvironment::layout() const
+{
+       return layout_;
 }