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(BufferParams const & bp,
43 TextClassIndex tc, string const & layoutName)
44 : InsetCollapsable(bp, Collapsed, tc),
47 setLayout(tc); // again, because now the name is initialized
48 packages_ = getLayout().requires();
49 preamble_ = getLayout().preamble();
53 InsetFlex::InsetFlex(InsetFlex const & in)
54 : InsetCollapsable(in), name_(in.name_)
58 Inset * InsetFlex::clone() const
60 return new InsetFlex(*this);
64 docstring const InsetFlex::editMessage() const
66 return _("Opened Flex Inset");
70 void InsetFlex::write(Buffer const & buf, ostream & os) const
73 (name_.empty() ? "undefined" : name_) << "\n";
74 InsetCollapsable::write(buf, os);
78 void InsetFlex::read(Buffer const & buf, Lexer & lex)
82 string token = lex.getString();
84 if (token == "Flex") {
86 name_ = lex.getString();
89 // This is handled in Collapsable
90 else if (token == "status") {
95 InsetCollapsable::read(buf, lex);
99 int InsetFlex::plaintext(Buffer const & buf, odocstream & os,
100 OutputParams const & runparams) const
102 return InsetText::plaintext(buf, os, runparams);
106 int InsetFlex::docbook(Buffer const & buf, odocstream & os,
107 OutputParams const & runparams) const
109 ParagraphList::const_iterator beg = paragraphs().begin();
110 ParagraphList::const_iterator par = paragraphs().begin();
111 ParagraphList::const_iterator end = paragraphs().end();
114 sgml::openTag(os, getLayout().latexname(),
115 par->getID(buf, runparams) + getLayout().latexparam());
117 for (; par != end; ++par) {
118 par->simpleDocBookOnePar(buf, os, runparams,
119 outerFont(distance(beg, par),
124 sgml::closeTag(os, getLayout().latexname());
130 void InsetFlex::textString(Buffer const & buf, odocstream & os) const
132 os << paragraphs().begin()->asString(buf, true);
136 void InsetFlex::validate(LaTeXFeatures & features) const
138 if (!preamble_.empty())
139 features.addPreambleSnippet(preamble_);
140 features.require(packages_);