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,
43 DocumentClass * dc, string const & layoutName)
44 : InsetCollapsable(buf, Collapsed, dc),
47 setLayout(dc); // 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 docstring InsetFlex::editMessage() const
60 return _("Opened Flex Inset");
64 void InsetFlex::write(ostream & os) const
67 (name_.empty() ? "undefined" : name_) << "\n";
68 InsetCollapsable::write(os);
72 void InsetFlex::read(Lexer & lex)
76 string token = lex.getString();
78 if (token == "Flex") {
80 name_ = lex.getString();
83 // This is handled in Collapsable
84 else if (token == "status") {
89 InsetCollapsable::read(lex);
93 int InsetFlex::plaintext(odocstream & os, OutputParams const & runparams) const
95 return InsetText::plaintext(os, runparams);
99 int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const
101 ParagraphList::const_iterator beg = paragraphs().begin();
102 ParagraphList::const_iterator par = paragraphs().begin();
103 ParagraphList::const_iterator end = paragraphs().end();
106 sgml::openTag(os, getLayout().latexname(),
107 par->getID(buffer(), runparams) + getLayout().latexparam());
109 for (; par != end; ++par) {
110 par->simpleDocBookOnePar(buffer(), os, runparams,
111 outerFont(distance(beg, par),
116 sgml::closeTag(os, getLayout().latexname());
122 void InsetFlex::textString(odocstream & os) const
124 os << paragraphs().begin()->asString(true);
128 void InsetFlex::validate(LaTeXFeatures & features) const
130 if (!preamble_.empty())
131 features.addPreambleSnippet(preamble_);
132 features.require(packages_);