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"
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"
44 InsetFlex::InsetFlex(BufferParams const & bp,
45 InsetLayout const & il)
46 : InsetCollapsable(bp, Collapsed, &il)
52 InsetFlex::InsetFlex(InsetFlex const & in)
53 : InsetCollapsable(in), name_(in.name_)
57 Inset * InsetFlex::clone() const
59 return new InsetFlex(*this);
63 bool InsetFlex::undefined() const
65 return layout_->labelstring == from_utf8("UNDEFINED");
69 docstring const InsetFlex::editMessage() const
71 return _("Opened Flex Inset");
75 void InsetFlex::write(Buffer const & buf, ostream & os) const
77 os << "Flex " << name_ << "\n";
78 InsetCollapsable::write(buf, os);
82 void InsetFlex::read(Buffer const & buf, Lexer & lex)
86 string token = lex.getString();
88 if (token == "Flex") {
90 name_ = lex.getString();
93 // This is handled in Collapsable
94 else if (token == "status") {
99 InsetCollapsable::read(buf, lex);
103 int InsetFlex::plaintext(Buffer const & buf, odocstream & os,
104 OutputParams const & runparams) const
106 return InsetText::plaintext(buf, os, runparams);
110 int InsetFlex::docbook(Buffer const & buf, odocstream & os,
111 OutputParams const & runparams) const
113 ParagraphList::const_iterator beg = paragraphs().begin();
114 ParagraphList::const_iterator par = paragraphs().begin();
115 ParagraphList::const_iterator end = paragraphs().end();
118 sgml::openTag(os, layout_->latexname,
119 par->getID(buf, runparams) + layout_->latexparam);
121 for (; par != end; ++par) {
122 par->simpleDocBookOnePar(buf, os, runparams,
123 outerFont(distance(beg, par),
128 sgml::closeTag(os, layout_->latexname);
134 void InsetFlex::textString(Buffer const & buf, odocstream & os) const
136 os << paragraphs().begin()->asString(buf, true);