7 #include "insetfloatlist.h"
9 #include "LaTeXFeatures.h"
11 #include "frontends/Dialogs.h"
12 #include "frontends/LyXView.h"
13 #include "BufferView.h"
24 InsetFloatList::InsetFloatList()
25 : InsetCommand(InsetCommandParams())
30 InsetFloatList::InsetFloatList(string const & type)
31 : InsetCommand(InsetCommandParams())
37 string const InsetFloatList::getScreenLabel(Buffer const * buf) const
39 FloatList const & floats = buf->params.getLyXTextClass().floats();
40 FloatList::const_iterator it = floats[getCmdName()];
41 if (it != floats.end())
42 return _(it->second.listName());
44 return _("ERROR: Nonexistent float type!");
48 Inset::Code InsetFloatList::lyxCode() const
50 return Inset::FLOAT_LIST_CODE;
54 void InsetFloatList::write(Buffer const *, ostream & os) const
56 os << "FloatList " << getCmdName() << "\n";
60 void InsetFloatList::read(Buffer const * buf, LyXLex & lex)
62 FloatList const & floats = buf->params.getLyXTextClass().floats();
66 setCmdName(lex.getString());
67 lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
68 if (!floats.typeExist(getCmdName()))
69 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
71 lex.printError("InsetFloatList: Parse error: `$$Token'");
74 token = lex.getString();
75 if (token == "\\end_inset")
78 if (token != "\\end_inset") {
79 lex.printError("Missing \\end_inset at this point. "
85 void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
87 bv->owner()->getDialogs().showTOC(this);
91 void InsetFloatList::edit(BufferView * bv, bool)
93 edit(bv, 0, 0, mouse_button::none);
97 int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
99 FloatList const & floats = buf->params.getLyXTextClass().floats();
100 FloatList::const_iterator cit = floats[getCmdName()];
102 if (cit != floats.end()) {
103 if (cit->second.builtin()) {
104 // Only two different types allowed here:
105 string const type = cit->second.type();
106 if (type == "table") {
107 os << "\\listoftables\n";
108 } else if (type == "figure") {
109 os << "\\listoffigures\n";
111 os << "%% unknown builtin float\n";
114 os << "\\listof{" << getCmdName() << "}{"
115 << cit->second.listName() << "}\n";
118 os << "%%\\listof{" << getCmdName() << "}{"
119 << _("List of ") << cit->second.name() << "}\n";
125 int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
127 os << getScreenLabel(buffer) << "\n\n";
129 toc::asciiTocList(getCmdName(), buffer, os);
136 void InsetFloatList::validate(LaTeXFeatures & features) const
138 features.useFloat(getCmdName());