7 #include "insetfloatlist.h"
9 #include "frontends/Dialogs.h"
11 #include "BufferView.h"
18 InsetFloatList::InsetFloatList()
19 : InsetCommand(InsetCommandParams())
24 InsetFloatList::InsetFloatList(string const & type)
25 : InsetCommand(InsetCommandParams())
31 string const InsetFloatList::getScreenLabel(Buffer const *) const
33 string const guiName = floatList[getCmdName()]->second.name();
34 if (!guiName.empty()) {
35 string const res = guiName + _(" List");
38 return _("ERROR: Nonexistent float type!");
42 Inset::Code InsetFloatList::lyxCode() const
44 return Inset::FLOAT_LIST_CODE;
48 void InsetFloatList::write(Buffer const *, std::ostream & os) const
50 os << "FloatList " << getCmdName() << "\n";
54 void InsetFloatList::read(Buffer const *, LyXLex & lex)
59 setCmdName(lex.getString());
60 lyxerr << "FloatList::float_type: " << getCmdName() << endl;
62 lex.printError("InsetFloatList: Parse error: `$$Token'");
65 token = lex.getString();
66 if (token == "\\end_inset")
69 if (token != "\\end_inset") {
70 lex.printError("Missing \\end_inset at this point. "
76 void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
78 bv->owner()->getDialogs()->showTOC(this);
82 void InsetFloatList::edit(BufferView * bv, bool)
88 int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
90 FloatList::const_iterator cit = floatList[getCmdName()];
92 if (cit != floatList.end()) {
93 if (cit->second.builtin()) {
94 // Only two different types allowed here:
95 string const type = cit->second.type();
96 if (type == "table") {
97 os << "\\listoftables\n";
98 } else if (type == "figure") {
99 os << "\\listoffigures\n";
101 os << "%% unknown builtin float\n";
104 os << "\\listof{" << getCmdName() << "}{"
105 << _("List of ") << cit->second.name() << "}\n";
108 os << "%%\\listof{" << getCmdName() << "}{"
109 << _("List of ") << cit->second.name() << "}\n";
115 int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
117 os << getScreenLabel(buffer) << "\n\n";
119 Buffer::Lists const toc_list = buffer->getLists();
120 Buffer::Lists::const_iterator cit =
121 toc_list.find(getCmdName());
122 if (cit != toc_list.end()) {
123 Buffer::SingleList::const_iterator ccit = cit->second.begin();
124 Buffer::SingleList::const_iterator end = cit->second.end();
125 for (; ccit != end; ++ccit)
126 os << string(4 * ccit->depth, ' ')
127 << ccit->str << "\n";