7 #include "insetfloatlist.h"
9 #include "LaTeXFeatures.h"
11 #include "frontends/Dialogs.h"
12 #include "frontends/LyXView.h"
13 #include "BufferView.h"
23 InsetFloatList::InsetFloatList()
24 : InsetCommand(InsetCommandParams())
29 InsetFloatList::InsetFloatList(string const & type)
30 : InsetCommand(InsetCommandParams())
36 string const InsetFloatList::getScreenLabel(Buffer const *) const
38 FloatList::const_iterator it = floatList[getCmdName()];
39 if (it != floatList.end())
40 return _(it->second.listName());
42 return _("ERROR: Nonexistent float type!");
46 Inset::Code InsetFloatList::lyxCode() const
48 return Inset::FLOAT_LIST_CODE;
52 void InsetFloatList::write(Buffer const *, ostream & os) const
54 os << "FloatList " << getCmdName() << "\n";
58 void InsetFloatList::read(Buffer const *, LyXLex & lex)
63 setCmdName(lex.getString());
64 lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
65 if (!floatList.typeExist(getCmdName()))
66 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
68 lex.printError("InsetFloatList: Parse error: `$$Token'");
71 token = lex.getString();
72 if (token == "\\end_inset")
75 if (token != "\\end_inset") {
76 lex.printError("Missing \\end_inset at this point. "
82 void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
84 bv->owner()->getDialogs().showTOC(this);
88 void InsetFloatList::edit(BufferView * bv, bool)
90 edit(bv, 0, 0, mouse_button::none);
94 int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
96 FloatList::const_iterator cit = floatList[getCmdName()];
98 if (cit != floatList.end()) {
99 if (cit->second.builtin()) {
100 // Only two different types allowed here:
101 string const type = cit->second.type();
102 if (type == "table") {
103 os << "\\listoftables\n";
104 } else if (type == "figure") {
105 os << "\\listoffigures\n";
107 os << "%% unknown builtin float\n";
110 os << "\\listof{" << getCmdName() << "}{"
111 << cit->second.listName() << "}\n";
114 os << "%%\\listof{" << getCmdName() << "}{"
115 << _("List of ") << cit->second.name() << "}\n";
121 int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
123 os << getScreenLabel(buffer) << "\n\n";
125 toc::asciiTocList(getCmdName(), buffer, os);
132 void InsetFloatList::validate(LaTeXFeatures & features) const
134 features.useFloat(getCmdName());