X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetFlex.cpp;h=279f9940542a2327f2fd1d300e5cf3b1bb4bf3b7;hb=0362c6aae73c293d1c20277c12d362acfe0b2ef6;hp=81bd94867a76d5e4d62e1abeef8abab6b52789e8;hpb=adfa69440d776cb20098fef09b569af4d576d772;p=lyx.git diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 81bd94867a..279f994054 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -21,7 +21,8 @@ #include "FuncRequest.h" #include "FuncStatus.h" #include "Cursor.h" -#include "gettext.h" +#include "support/gettext.h" +#include "LaTeXFeatures.h" #include "Lexer.h" #include "Text.h" #include "MetricsInfo.h" @@ -29,25 +30,23 @@ #include "paragraph_funcs.h" #include "sgml.h" -#include "frontends/FontMetrics.h" -#include "frontends/Painter.h" - #include "support/convert.h" #include +using namespace std; namespace lyx { -using std::string; -using std::ostream; - InsetFlex::InsetFlex(BufferParams const & bp, - InsetLayout const & il) - : InsetCollapsable(bp, Collapsed, &il) + TextClassPtr tc, string const & layoutName) + : InsetCollapsable(bp, Collapsed, tc), + name_(layoutName) { - name_ = il.name; + setLayout(tc); // again, because now the name is initialized + packages_ = getLayout().requires(); + preamble_ = getLayout().preamble(); } @@ -62,12 +61,6 @@ Inset * InsetFlex::clone() const } -bool InsetFlex::undefined() const -{ - return layout_->labelstring == from_utf8("UNDEFINED"); -} - - docstring const InsetFlex::editMessage() const { return _("Opened Flex Inset"); @@ -76,7 +69,8 @@ docstring const InsetFlex::editMessage() const void InsetFlex::write(Buffer const & buf, ostream & os) const { - os << "Flex " << name_ << "\n"; + os << "Flex " << + (name_.empty() ? "undefined" : name_) << "\n"; InsetCollapsable::write(buf, os); } @@ -117,17 +111,17 @@ int InsetFlex::docbook(Buffer const & buf, odocstream & os, ParagraphList::const_iterator end = paragraphs().end(); if (!undefined()) - sgml::openTag(os, layout_->latexname, - par->getID(buf, runparams) + layout_->latexparam); + sgml::openTag(os, getLayout().latexname(), + par->getID(buf, runparams) + getLayout().latexparam()); for (; par != end; ++par) { par->simpleDocBookOnePar(buf, os, runparams, - outerFont(std::distance(beg, par), + outerFont(distance(beg, par), paragraphs())); } if (!undefined()) - sgml::closeTag(os, layout_->latexname); + sgml::closeTag(os, getLayout().latexname()); return 0; } @@ -138,4 +132,12 @@ void InsetFlex::textString(Buffer const & buf, odocstream & os) const os << paragraphs().begin()->asString(buf, true); } + +void InsetFlex::validate(LaTeXFeatures & features) const +{ + if (!preamble_.empty()) + features.addPreambleSnippet(preamble_); + features.require(packages_); +} + } // namespace lyx