2001-05-04 10:36:36 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetfloatlist.h"
|
|
|
|
#include "FloatList.h"
|
2002-04-04 14:39:55 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2001-11-27 10:56:14 +00:00
|
|
|
#include "frontends/Dialogs.h"
|
2002-05-23 12:08:47 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2001-11-27 10:56:14 +00:00
|
|
|
#include "BufferView.h"
|
2001-05-04 10:36:36 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
2001-05-04 13:17:01 +00:00
|
|
|
using std::endl;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2001-11-27 10:56:14 +00:00
|
|
|
InsetFloatList::InsetFloatList()
|
|
|
|
: InsetCommand(InsetCommandParams())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2001-11-27 10:56:14 +00:00
|
|
|
InsetFloatList::InsetFloatList(string const & type)
|
|
|
|
: InsetCommand(InsetCommandParams())
|
|
|
|
{
|
|
|
|
setCmdName(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
string const InsetFloatList::getScreenLabel(Buffer const *) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
2002-04-28 14:00:48 +00:00
|
|
|
FloatList::const_iterator it = floatList[getCmdName()];
|
|
|
|
if (it != floatList.end())
|
|
|
|
return _(it->second.listName());
|
|
|
|
else
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
void InsetFloatList::write(Buffer const *, ostream & os) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
2001-11-27 10:56:14 +00:00
|
|
|
os << "FloatList " << getCmdName() << "\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +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()) {
|
2001-11-27 10:56:14 +00:00
|
|
|
setCmdName(lex.getString());
|
2002-04-28 14:00:48 +00:00
|
|
|
lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
|
|
|
|
if (!floatList.typeExist(getCmdName()))
|
|
|
|
lex.printError("InsetFloatList: Unknown float type: `$$Token'");
|
2001-05-04 10:36:36 +00:00
|
|
|
} 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-11-27 10:56:14 +00:00
|
|
|
void InsetFloatList::edit(BufferView * bv, int, int, unsigned int)
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
2001-11-27 10:56:14 +00:00
|
|
|
bv->owner()->getDialogs()->showTOC(this);
|
2001-05-04 10:36:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
void InsetFloatList::edit(BufferView * bv, bool)
|
|
|
|
{
|
|
|
|
edit(bv, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
|
2001-05-04 10:36:36 +00:00
|
|
|
{
|
2001-11-27 10:56:14 +00:00
|
|
|
FloatList::const_iterator cit = floatList[getCmdName()];
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
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 {
|
2001-11-27 10:56:14 +00:00
|
|
|
os << "\\listof{" << getCmdName() << "}{"
|
2002-04-04 14:39:55 +00:00
|
|
|
<< cit->second.listName() << "}\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-11-27 10:56:14 +00:00
|
|
|
os << "%%\\listof{" << getCmdName() << "}{"
|
2001-05-04 10:36:36 +00:00
|
|
|
<< _("List of ") << cit->second.name() << "}\n";
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
int InsetFloatList::ascii(Buffer const * buffer, 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 =
|
2001-11-27 10:56:14 +00:00
|
|
|
toc_list.find(getCmdName());
|
2001-05-04 10:36:36 +00:00
|
|
|
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;
|
|
|
|
}
|
2002-04-04 14:39:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
void InsetFloatList::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
features.useFloat(getCmdName());
|
|
|
|
}
|