2 * \file insetfloatlist.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
13 #include "insetfloatlist.h"
16 #include "bufferparams.h"
18 #include "dispatchresult.h"
20 #include "FloatList.h"
21 #include "funcrequest.h"
23 #include "LaTeXFeatures.h"
25 #include "metricsinfo.h"
28 #include "support/lstrings.h"
33 using support::bformat;
40 InsetFloatList::InsetFloatList()
41 : InsetCommand(InsetCommandParams("floatlist"), "toc")
45 InsetFloatList::InsetFloatList(string const & type)
46 : InsetCommand(InsetCommandParams("floatlist"), "toc")
52 docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
54 FloatList const & floats = buf.params().getLyXTextClass().floats();
55 FloatList::const_iterator it = floats[getCmdName()];
56 if (it != floats.end())
57 return buf.B_(it->second.listName());
59 return _("ERROR: Nonexistent float type!");
63 InsetBase::Code InsetFloatList::lyxCode() const
65 return InsetBase::FLOAT_LIST_CODE;
69 void InsetFloatList::write(Buffer const &, ostream & os) const
71 os << "FloatList " << getCmdName() << "\n";
75 void InsetFloatList::read(Buffer const & buf, LyXLex & lex)
77 InsetCommand::read(buf, lex);
78 lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
79 if (!buf.params().getLyXTextClass().floats().typeExist(getCmdName()))
80 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
84 int InsetFloatList::latex(Buffer const & buf, odocstream & os,
85 OutputParams const &) const
87 FloatList const & floats = buf.params().getLyXTextClass().floats();
88 FloatList::const_iterator cit = floats[getCmdName()];
90 if (cit != floats.end()) {
91 if (cit->second.builtin()) {
92 // Only two different types allowed here:
93 string const type = cit->second.type();
94 if (type == "table") {
95 os << "\\listoftables\n";
96 } else if (type == "figure") {
97 os << "\\listoffigures\n";
99 os << "%% unknown builtin float\n";
103 os << "\\listof{" << from_ascii(getCmdName()) << "}{"
104 << buf.B_(cit->second.listName()) << "}\n";
108 os << "%%\\listof{" << from_ascii(getCmdName()) << "}{"
109 << bformat(_("List of %1$s"), from_utf8(cit->second.name()))
116 int InsetFloatList::plaintext(Buffer const & buffer, odocstream & os,
117 OutputParams const &) const
119 os << getScreenLabel(buffer) << "\n\n";
121 toc::asciiTocList(getCmdName(), buffer, os);
128 void InsetFloatList::validate(LaTeXFeatures & features) const
130 features.useFloat(getCmdName());