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 "BufferView.h"
20 #include "DispatchResult.h"
21 #include "FuncRequest.h"
22 #include "FuncStatus.h"
24 #include "support/gettext.h"
25 #include "LaTeXFeatures.h"
28 #include "MetricsInfo.h"
29 #include "Paragraph.h"
30 #include "paragraph_funcs.h"
33 #include "support/convert.h"
42 InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
43 : InsetCollapsable(buf, Collapsed), name_(layoutName)
45 // again, because now the name is initialized
46 setLayout(buf.params().documentClassPtr());
47 packages_ = getLayout().requires();
48 preamble_ = getLayout().preamble();
52 InsetFlex::InsetFlex(InsetFlex const & in)
53 : InsetCollapsable(in), name_(in.name_)
57 docstring InsetFlex::editMessage() const
59 return _("Opened Flex Inset");
63 void InsetFlex::write(ostream & os) const
66 (name_.empty() ? "undefined" : name_) << "\n";
67 InsetCollapsable::write(os);
71 void InsetFlex::read(Lexer & lex)
76 if (token == "Flex") {
78 name_ = lex.getString();
79 } else if (token == "status") {
80 // This is handled in Collapsable
85 InsetCollapsable::read(lex);
89 int InsetFlex::plaintext(odocstream & os, OutputParams const & runparams) const
91 return InsetText::plaintext(os, runparams);
95 int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const
97 ParagraphList::const_iterator beg = paragraphs().begin();
98 ParagraphList::const_iterator par = paragraphs().begin();
99 ParagraphList::const_iterator end = paragraphs().end();
102 sgml::openTag(os, getLayout().latexname(),
103 par->getID(buffer(), runparams) + getLayout().latexparam());
105 for (; par != end; ++par) {
106 par->simpleDocBookOnePar(buffer(), os, runparams,
107 outerFont(distance(beg, par),
112 sgml::closeTag(os, getLayout().latexname());
118 void InsetFlex::textString(odocstream & os) const
120 os << paragraphs().begin()->asString(true);
124 void InsetFlex::validate(LaTeXFeatures & features) const
126 if (!preamble_.empty())
127 features.addPreambleSnippet(preamble_);
128 features.require(packages_);