]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetenv.C
Clean up InsetGraphics::Cache and rename as GraphicsInset.
[lyx.git] / src / insets / insetenv.C
index 52e478f35abd47d00b3b75b35b4dbeb349452f5c..1158b1a1d0edb1975fc1dd7749ff25b4c2633b3c 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"
@@ -26,30 +27,22 @@ using std::endl;
 
 InsetEnvironment::InsetEnvironment
                (BufferParams const & bp, string const & name)
-       : InsetText(bp)
+       : InsetText(bp), layout_(bp.getLyXTextClass()[name])
 {
-       //setLabel(name);
        setInsetName(name);
        autoBreakRows = true;
        drawFrame_ = ALWAYS;
-       // 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;
-       header_ = "\\begin{" + name + "}";
-       footer_ = "\\end{" + name + "}";
 }
 
 
-InsetEnvironment::InsetEnvironment(InsetEnvironment const & in, bool same_id)
-       : InsetText(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
+Inset * InsetEnvironment::clone() const
 {
-       return new InsetEnvironment(*this, same_id);
+       return new InsetEnvironment(*this);
 }
 
 
@@ -72,11 +65,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 = InsetText::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_;
 }