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"
14 #include "FloatList.h"
15 #include "LaTeXFeatures.h"
17 #include "frontends/Dialogs.h"
18 #include "frontends/LyXView.h"
19 #include "BufferView.h"
25 #include "BoostFormat.h"
31 InsetFloatList::InsetFloatList()
32 : InsetCommand(InsetCommandParams())
37 InsetFloatList::InsetFloatList(string const & type)
38 : InsetCommand(InsetCommandParams())
44 InsetFloatList::~InsetFloatList()
46 InsetCommandMailer mailer("toc", *this);
51 string 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 _(it->second.listName());
58 return _("ERROR: Nonexistent float type!");
62 Inset::Code InsetFloatList::lyxCode() const
64 return Inset::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 FloatList const & floats = buf->params.getLyXTextClass().floats();
80 setCmdName(lex.getString());
81 lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
82 if (!floats.typeExist(getCmdName()))
83 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
85 lex.printError("InsetFloatList: Parse error: `$$Token'");
88 token = lex.getString();
89 if (token == "\\end_inset")
92 if (token != "\\end_inset") {
93 lex.printError("Missing \\end_inset at this point. "
99 void InsetFloatList::edit(BufferView *, int, int, mouse_button::state)
101 InsetCommandMailer mailer("toc", *this);
106 void InsetFloatList::edit(BufferView * bv, bool)
108 edit(bv, 0, 0, mouse_button::none);
112 int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
114 FloatList const & floats = buf->params.getLyXTextClass().floats();
115 FloatList::const_iterator cit = floats[getCmdName()];
117 if (cit != floats.end()) {
118 if (cit->second.builtin()) {
119 // Only two different types allowed here:
120 string const type = cit->second.type();
121 if (type == "table") {
122 os << "\\listoftables\n";
123 } else if (type == "figure") {
124 os << "\\listoffigures\n";
126 os << "%% unknown builtin float\n";
129 os << "\\listof{" << getCmdName() << "}{"
130 << cit->second.listName() << "}\n";
137 << boost::format(_("List of %1$s")) % cit->second.name()
143 << _("List of ") << cit->second.name()
151 int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
153 os << getScreenLabel(buffer) << "\n\n";
155 toc::asciiTocList(getCmdName(), buffer, os);
162 void InsetFloatList::validate(LaTeXFeatures & features) const
164 features.useFloat(getCmdName());