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 string const InsetFloatList::getScreenLabel(Buffer const * buf) const
46 FloatList const & floats = buf->params.getLyXTextClass().floats();
47 FloatList::const_iterator it = floats[getCmdName()];
48 if (it != floats.end())
49 return _(it->second.listName());
51 return _("ERROR: Nonexistent float type!");
55 Inset::Code InsetFloatList::lyxCode() const
57 return Inset::FLOAT_LIST_CODE;
61 void InsetFloatList::write(Buffer const *, ostream & os) const
63 os << "FloatList " << getCmdName() << "\n";
67 void InsetFloatList::read(Buffer const * buf, LyXLex & lex)
69 FloatList const & floats = buf->params.getLyXTextClass().floats();
73 setCmdName(lex.getString());
74 lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
75 if (!floats.typeExist(getCmdName()))
76 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
78 lex.printError("InsetFloatList: Parse error: `$$Token'");
81 token = lex.getString();
82 if (token == "\\end_inset")
85 if (token != "\\end_inset") {
86 lex.printError("Missing \\end_inset at this point. "
92 void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
94 bv->owner()->getDialogs().showTOC(this);
98 void InsetFloatList::edit(BufferView * bv, bool)
100 edit(bv, 0, 0, mouse_button::none);
104 int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
106 FloatList const & floats = buf->params.getLyXTextClass().floats();
107 FloatList::const_iterator cit = floats[getCmdName()];
109 if (cit != floats.end()) {
110 if (cit->second.builtin()) {
111 // Only two different types allowed here:
112 string const type = cit->second.type();
113 if (type == "table") {
114 os << "\\listoftables\n";
115 } else if (type == "figure") {
116 os << "\\listoffigures\n";
118 os << "%% unknown builtin float\n";
121 os << "\\listof{" << getCmdName() << "}{"
122 << cit->second.listName() << "}\n";
129 << boost::format(_("List of %1$s")) % cit->second.name()
135 << _("List of ") << cit->second.name()
143 int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
145 os << getScreenLabel(buffer) << "\n\n";
147 toc::asciiTocList(getCmdName(), buffer, os);
154 void InsetFloatList::validate(LaTeXFeatures & features) const
156 features.useFloat(getCmdName());