7 #include "insetfloatlist.h"
9 #include "LaTeXFeatures.h"
10 #include "frontends/Dialogs.h"
12 #include "BufferView.h"
22 InsetFloatList::InsetFloatList()
23 : InsetCommand(InsetCommandParams())
28 InsetFloatList::InsetFloatList(string const & type)
29 : InsetCommand(InsetCommandParams())
35 string const InsetFloatList::getScreenLabel(Buffer const *) const
37 string const guiName = floatList[getCmdName()]->second.listName();
38 if (!guiName.empty()) {
41 return _("ERROR: Nonexistent float type!");
45 Inset::Code InsetFloatList::lyxCode() const
47 return Inset::FLOAT_LIST_CODE;
51 void InsetFloatList::write(Buffer const *, ostream & os) const
53 os << "FloatList " << getCmdName() << "\n";
57 void InsetFloatList::read(Buffer const *, LyXLex & lex)
62 setCmdName(lex.getString());
63 lyxerr << "FloatList::float_type: " << getCmdName() << endl;
65 lex.printError("InsetFloatList: Parse error: `$$Token'");
68 token = lex.getString();
69 if (token == "\\end_inset")
72 if (token != "\\end_inset") {
73 lex.printError("Missing \\end_inset at this point. "
79 void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
81 bv->owner()->getDialogs()->showTOC(this);
85 void InsetFloatList::edit(BufferView * bv, bool)
91 int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
93 FloatList::const_iterator cit = floatList[getCmdName()];
95 if (cit != floatList.end()) {
96 if (cit->second.builtin()) {
97 // Only two different types allowed here:
98 string const type = cit->second.type();
99 if (type == "table") {
100 os << "\\listoftables\n";
101 } else if (type == "figure") {
102 os << "\\listoffigures\n";
104 os << "%% unknown builtin float\n";
107 os << "\\listof{" << getCmdName() << "}{"
108 << cit->second.listName() << "}\n";
111 os << "%%\\listof{" << getCmdName() << "}{"
112 << _("List of ") << cit->second.name() << "}\n";
118 int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
120 os << getScreenLabel(buffer) << "\n\n";
122 Buffer::Lists const toc_list = buffer->getLists();
123 Buffer::Lists::const_iterator cit =
124 toc_list.find(getCmdName());
125 if (cit != toc_list.end()) {
126 Buffer::SingleList::const_iterator ccit = cit->second.begin();
127 Buffer::SingleList::const_iterator end = cit->second.end();
128 for (; ccit != end; ++ccit)
129 os << string(4 * ccit->depth, ' ')
130 << ccit->str << "\n";
138 void InsetFloatList::validate(LaTeXFeatures & features) const
140 features.useFloat(getCmdName());