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 FloatList::const_iterator it = floatList[getCmdName()];
38 if (it != floatList.end())
39 return _(it->second.listName());
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[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
64 if (!floatList.typeExist(getCmdName()))
65 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
67 lex.printError("InsetFloatList: Parse error: `$$Token'");
70 token = lex.getString();
71 if (token == "\\end_inset")
74 if (token != "\\end_inset") {
75 lex.printError("Missing \\end_inset at this point. "
81 void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
83 bv->owner()->getDialogs()->showTOC(this);
87 void InsetFloatList::edit(BufferView * bv, bool)
93 int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
95 FloatList::const_iterator cit = floatList[getCmdName()];
97 if (cit != floatList.end()) {
98 if (cit->second.builtin()) {
99 // Only two different types allowed here:
100 string const type = cit->second.type();
101 if (type == "table") {
102 os << "\\listoftables\n";
103 } else if (type == "figure") {
104 os << "\\listoffigures\n";
106 os << "%% unknown builtin float\n";
109 os << "\\listof{" << getCmdName() << "}{"
110 << cit->second.listName() << "}\n";
113 os << "%%\\listof{" << getCmdName() << "}{"
114 << _("List of ") << cit->second.name() << "}\n";
120 int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
122 os << getScreenLabel(buffer) << "\n\n";
124 Buffer::Lists const toc_list = buffer->getLists();
125 Buffer::Lists::const_iterator cit =
126 toc_list.find(getCmdName());
127 if (cit != toc_list.end()) {
128 Buffer::SingleList::const_iterator ccit = cit->second.begin();
129 Buffer::SingleList::const_iterator end = cit->second.end();
130 for (; ccit != end; ++ccit)
131 os << string(4 * ccit->depth, ' ')
132 << ccit->str << "\n";
140 void InsetFloatList::validate(LaTeXFeatures & features) const
142 features.useFloat(getCmdName());