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"
27 #include "MetricsInfo.h"
28 #include "Paragraph.h"
29 #include "paragraph_funcs.h"
32 #include "frontends/FontMetrics.h"
33 #include "frontends/Painter.h"
35 #include "support/convert.h"
46 InsetFlex::InsetFlex(BufferParams const & bp,
48 : InsetCollapsable(bp, Collapsed)
50 params_.name = il.name;
55 InsetFlex::InsetFlex(InsetFlex const & in)
56 : InsetCollapsable(in), params_(in.params_)
60 Inset * InsetFlex::clone() const
62 return new InsetFlex(*this);
66 bool InsetFlex::undefined() const
68 return layout_.labelstring == from_utf8("UNDEFINED");
72 void InsetFlex::setLayout(InsetLayout il)
78 docstring const InsetFlex::editMessage() const
80 return _("Opened Flex Inset");
84 void InsetFlex::write(Buffer const & buf, ostream & os) const
87 InsetCollapsable::write(buf, os);
91 void InsetFlex::read(Buffer const & buf, Lexer & lex)
94 InsetCollapsable::read(buf, lex);
98 int InsetFlex::plaintext(Buffer const & buf, odocstream & os,
99 OutputParams const & runparams) const
101 return InsetText::plaintext(buf, os, runparams);
105 int InsetFlex::docbook(Buffer const & buf, odocstream & os,
106 OutputParams const & runparams) const
108 ParagraphList::const_iterator beg = paragraphs().begin();
109 ParagraphList::const_iterator par = paragraphs().begin();
110 ParagraphList::const_iterator end = paragraphs().end();
114 sgml::openTag(os, layout_.latexname,
115 par->getID(buf, runparams) + layout_.latexparam);
117 for (; par != end; ++par) {
118 par->simpleDocBookOnePar(buf, os, runparams,
119 outerFont(std::distance(beg, par),
124 sgml::closeTag(os, layout_.latexname);
130 void InsetFlex::textString(Buffer const & buf, odocstream & os) const
132 os << paragraphs().begin()->asString(buf, true);
136 void InsetFlexParams::write(ostream & os) const
138 os << "Flex " << name << "\n";
142 void InsetFlexParams::read(Lexer & lex)
146 string token = lex.getString();
148 if (token == "Flex") {
150 name = lex.getString();
153 // This is handled in Collapsable
154 else if (token == "status") {
155 lex.pushToken(token);