X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetenv.C;h=fd2d2cca4fecf2f374c78977f9afed1094a5f72c;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=74c200cda7659d015dcf8ce3c56c3cb7374313a9;hpb=1e0432dab60dffe27e78668031a12abf7ab2fb61;p=lyx.git diff --git a/src/insets/insetenv.C b/src/insets/insetenv.C index 74c200cda7..fd2d2cca4f 100644 --- a/src/insets/insetenv.C +++ b/src/insets/insetenv.C @@ -1,4 +1,3 @@ -// -*- C++ -*- /** * \file insetenv.C * This file is part of LyX, the document processor. @@ -6,73 +5,85 @@ * * \author André Pönitz * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include #include "insetenv.h" -#include "gettext.h" -#include "lyxtextclass.h" -#include "lyxlayout.h" + #include "bufferparams.h" -#include "support/LOstream.h" -#include "debug.h" +#include "gettext.h" +#include "paragraph.h" +#include "output_latex.h" +#include "texrow.h" +namespace lyx { + +using std::string; +using std::auto_ptr; using std::ostream; -using std::endl; 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; + setInsetName(from_utf8(name)); + setAutoBreakRows(true); + setDrawFrame(true); } -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 InsetEnvironment::doClone() const { - return new InsetEnvironment(*this, same_id); + return auto_ptr(new InsetEnvironment(*this)); } -void InsetEnvironment::write(Buffer const * buf, ostream & os) const +void InsetEnvironment::write(Buffer const & buf, ostream & os) const { - os << "Environment" << getInsetName() << "\"\n"; - InsetCollapsable::write(buf, os); + os << "Environment " << to_utf8(getInsetName()) << "\n"; + InsetText::write(buf, os); } -void InsetEnvironment::read(Buffer const * buf, LyXLex & lex) +void InsetEnvironment::read(Buffer const & buf, LyXLex & lex) { - InsetCollapsable::read(buf, lex); + InsetText::read(buf, lex); } -string const InsetEnvironment::editMessage() const +docstring const InsetEnvironment::editMessage() const { return _("Opened Environment Inset: ") + getInsetName(); } -int InsetEnvironment::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int InsetEnvironment::latex(Buffer const & buf, odocstream & os, + OutputParams const & runparams) const +{ + // FIXME UNICODE + os << from_utf8(layout_->latexheader); + TexRow texrow; + latexParagraphs(buf, paragraphs(), os, texrow, runparams, + layout_->latexparagraph); + // FIXME UNICODE + os << from_utf8(layout_->latexfooter); + return texrow.rows(); +} + + +LyXLayout_ptr const & InsetEnvironment::layout() const { - os << header_; - int i = inset.latex(buf, os, fragile, fp); - os << footer_; - return i; + return layout_; } + + +} // namespace lyx