3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
7 * \author Martin Vermeer
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "InsetFlex.h"
18 #include "BufferParams.h"
19 #include "LaTeXFeatures.h"
21 #include "MetricsInfo.h"
22 #include "Paragraph.h"
23 #include "paragraph_funcs.h"
27 #include "support/gettext.h"
36 InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
37 : InsetCollapsable(buf, Collapsed), name_(layoutName)
39 // again, because now the name is initialized
40 setLayout(buf.params().documentClassPtr());
44 InsetFlex::InsetFlex(InsetFlex const & in)
45 : InsetCollapsable(in), name_(in.name_)
49 docstring InsetFlex::editMessage() const
51 return _("Opened Flex Inset");
55 void InsetFlex::write(ostream & os) const
58 (name_.empty() ? "undefined" : name_) << "\n";
59 InsetCollapsable::write(os);
63 void InsetFlex::read(Lexer & lex)
68 if (token == "Flex") {
70 name_ = lex.getString();
71 } else if (token == "status") {
72 // This is handled in Collapsable
77 InsetCollapsable::read(lex);
81 int InsetFlex::plaintext(odocstream & os, OutputParams const & runparams) const
83 return InsetText::plaintext(os, runparams);
87 int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const
89 ParagraphList::const_iterator beg = paragraphs().begin();
90 ParagraphList::const_iterator par = paragraphs().begin();
91 ParagraphList::const_iterator end = paragraphs().end();
94 sgml::openTag(os, getLayout().latexname(),
95 par->getID(buffer(), runparams) + getLayout().latexparam());
97 for (; par != end; ++par) {
98 par->simpleDocBookOnePar(buffer(), os, runparams,
99 outerFont(distance(beg, par),
104 sgml::closeTag(os, getLayout().latexname());
110 void InsetFlex::textString(odocstream & os) const
112 os << paragraphs().begin()->asString(AS_STR_LABEL | AS_STR_INSETS);
116 void InsetFlex::validate(LaTeXFeatures & features) const
118 string const preamble = getLayout().preamble();
119 if (!preamble.empty())
120 features.addPreambleSnippet(preamble);
121 features.require(getLayout().requires());