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"
31 using lyx::odocstream;
32 using lyx::support::bformat;
39 InsetFloatList::InsetFloatList()
40 : InsetCommand(InsetCommandParams("floatlist"), "toc")
44 InsetFloatList::InsetFloatList(string const & type)
45 : InsetCommand(InsetCommandParams("floatlist"), "toc")
51 docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
53 FloatList const & floats = buf.params().getLyXTextClass().floats();
54 FloatList::const_iterator it = floats[getCmdName()];
55 if (it != floats.end())
56 return buf.B_(it->second.listName());
58 return _("ERROR: Nonexistent float type!");
62 InsetBase::Code InsetFloatList::lyxCode() const
64 return InsetBase::FLOAT_LIST_CODE;
68 void InsetFloatList::write(Buffer const &, ostream & os) const
70 os << "FloatList " << getCmdName() << "\n";
74 void InsetFloatList::read(Buffer const & buf, LyXLex & lex)
76 InsetCommand::read(buf, lex);
77 lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
78 if (!buf.params().getLyXTextClass().floats().typeExist(getCmdName()))
79 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
83 int InsetFloatList::latex(Buffer const & buf, odocstream & os,
84 OutputParams const &) const
86 FloatList const & floats = buf.params().getLyXTextClass().floats();
87 FloatList::const_iterator cit = floats[getCmdName()];
89 if (cit != floats.end()) {
90 if (cit->second.builtin()) {
91 // Only two different types allowed here:
92 string const type = cit->second.type();
93 if (type == "table") {
94 os << "\\listoftables\n";
95 } else if (type == "figure") {
96 os << "\\listoffigures\n";
98 os << "%% unknown builtin float\n";
102 os << "\\listof{" << lyx::from_ascii(getCmdName()) << "}{"
103 << buf.B_(cit->second.listName()) << "}\n";
107 os << "%%\\listof{" << lyx::from_ascii(getCmdName()) << "}{"
108 << bformat(_("List of %1$s"), lyx::from_utf8(cit->second.name()))
115 int InsetFloatList::plaintext(Buffer const & buffer, odocstream & os,
116 OutputParams const &) const
118 os << getScreenLabel(buffer) << "\n\n";
120 lyx::toc::asciiTocList(getCmdName(), buffer, os);
127 void InsetFloatList::validate(LaTeXFeatures & features) const
129 features.useFloat(getCmdName());