2001-05-04 10:36:36 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetfloatlist.h"
|
|
|
|
#include "FloatList.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
2001-05-04 13:17:01 +00:00
|
|
|
using std::endl;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
string const InsetFloatList::getScreenLabel(Buffer const *) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
|
|
|
string const guiName = floatList[float_type]->second.name();
|
|
|
|
if (!guiName.empty()) {
|
2001-08-16 10:28:56 +00:00
|
|
|
string const res = guiName + _(" List");
|
2001-05-04 10:36:36 +00:00
|
|
|
return res;
|
|
|
|
}
|
2001-09-20 10:16:24 +00:00
|
|
|
return _("ERROR: Nonexistent float type!");
|
2001-05-04 10:36:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
Inset::Code InsetFloatList::lyxCode() const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
|
|
|
return Inset::FLOAT_LIST_CODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetFloatList::write(Buffer const *, std::ostream & os) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
|
|
|
os << "FloatList " << float_type << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetFloatList::read(Buffer const *, LyXLex & lex)
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
|
|
|
string token;
|
|
|
|
|
2001-08-06 19:13:25 +00:00
|
|
|
if (lex.eatLine()) {
|
|
|
|
float_type = lex.getString();
|
2001-05-04 10:36:36 +00:00
|
|
|
lyxerr << "FloatList::float_type: " << float_type << endl;
|
|
|
|
} else
|
|
|
|
lex.printError("InsetFloatList: Parse error: `$$Token'");
|
2001-08-06 19:13:25 +00:00
|
|
|
while (lex.isOK()) {
|
2001-05-04 10:36:36 +00:00
|
|
|
lex.nextToken();
|
2001-08-06 19:13:25 +00:00
|
|
|
token = lex.getString();
|
2001-05-04 10:36:36 +00:00
|
|
|
if (token == "\\end_inset")
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (token != "\\end_inset") {
|
|
|
|
lex.printError("Missing \\end_inset at this point. "
|
|
|
|
"Read: `$$Token'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetFloatList::edit(BufferView *, int, int, unsigned int)
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
2001-08-19 13:13:47 +00:00
|
|
|
// FIX: Implement me please.
|
2001-05-04 10:36:36 +00:00
|
|
|
#if 0
|
|
|
|
bv->owner()->getDialogs()->showFloatList(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
void InsetFloatList::edit(BufferView * bv, bool)
|
|
|
|
{
|
|
|
|
edit(bv, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
|
|
|
FloatList::const_iterator cit = floatList[float_type];
|
|
|
|
|
|
|
|
|
|
|
|
if (cit != floatList.end()) {
|
|
|
|
if (cit->second.builtin()) {
|
|
|
|
// Only two different types allowed here:
|
|
|
|
string const type = cit->second.type();
|
|
|
|
if (type == "table") {
|
|
|
|
os << "\\listoftables\n";
|
|
|
|
} else if (type == "figure") {
|
|
|
|
os << "\\listoffigures\n";
|
|
|
|
} else {
|
|
|
|
os << "%% unknown builtin float\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
os << "\\listof{" << float_type << "}{"
|
|
|
|
<< _("List of ") << cit->second.name() << "}\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
os << "%%\\listof{" << float_type << "}{"
|
|
|
|
<< _("List of ") << cit->second.name() << "}\n";
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
2001-07-28 12:24:16 +00:00
|
|
|
os << getScreenLabel(buffer) << "\n\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
Buffer::Lists const toc_list = buffer->getLists();
|
|
|
|
Buffer::Lists::const_iterator cit =
|
|
|
|
toc_list.find(float_type);
|
|
|
|
if (cit != toc_list.end()) {
|
|
|
|
Buffer::SingleList::const_iterator ccit = cit->second.begin();
|
|
|
|
Buffer::SingleList::const_iterator end = cit->second.end();
|
|
|
|
for (; ccit != end; ++ccit)
|
|
|
|
os << string(4 * ccit->depth, ' ')
|
|
|
|
<< ccit->str << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
os << "\n";
|
|
|
|
return 0;
|
|
|
|
}
|