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,
47 InsetLayout const & il)
48 : InsetCollapsable(bp, Collapsed, &il)
50 params_.name = il.name;
54 InsetFlex::InsetFlex(InsetFlex const & in)
55 : InsetCollapsable(in), params_(in.params_)
59 Inset * InsetFlex::clone() const
61 return new InsetFlex(*this);
65 bool InsetFlex::undefined() const
67 return layout_->labelstring == from_utf8("UNDEFINED");
71 docstring const InsetFlex::editMessage() const
73 return _("Opened Flex Inset");
77 void InsetFlex::write(Buffer const & buf, ostream & os) const
80 InsetCollapsable::write(buf, os);
84 void InsetFlex::read(Buffer const & buf, Lexer & lex)
87 InsetCollapsable::read(buf, lex);
91 int InsetFlex::plaintext(Buffer const & buf, odocstream & os,
92 OutputParams const & runparams) const
94 return InsetText::plaintext(buf, os, runparams);
98 int InsetFlex::docbook(Buffer const & buf, odocstream & os,
99 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();
107 sgml::openTag(os, layout_->latexname,
108 par->getID(buf, runparams) + layout_->latexparam);
110 for (; par != end; ++par) {
111 par->simpleDocBookOnePar(buf, os, runparams,
112 outerFont(std::distance(beg, par),
117 sgml::closeTag(os, layout_->latexname);
123 void InsetFlex::textString(Buffer const & buf, odocstream & os) const
125 os << paragraphs().begin()->asString(buf, true);
129 void InsetFlexParams::write(ostream & os) const
131 os << "Flex " << name << "\n";
135 void InsetFlexParams::read(Lexer & lex)
139 string token = lex.getString();
141 if (token == "Flex") {
143 name = lex.getString();
146 // This is handled in Collapsable
147 else if (token == "status") {
148 lex.pushToken(token);