1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2000-07-14 07:52:03 +00:00
|
|
|
#include "gettext.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "insettoc.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
#include "BufferView.h"
|
2002-05-23 12:08:47 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2000-08-01 17:33:32 +00:00
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
#include "debug.h"
|
2001-01-11 14:55:36 +00:00
|
|
|
#include "buffer.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2001-03-15 10:31:00 +00:00
|
|
|
using std::vector;
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::ostream;
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
string const InsetTOC::getScreenLabel(Buffer const *) const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2001-04-27 07:58:56 +00:00
|
|
|
string const cmdname(getCmdName());
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2001-04-27 07:58:56 +00:00
|
|
|
if (cmdname == "tableofcontents")
|
2000-08-01 17:33:32 +00:00
|
|
|
return _("Table of Contents");
|
2001-05-04 10:36:36 +00:00
|
|
|
return _("Unknown toc list");
|
2000-08-01 17:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
Inset::Code InsetTOC::lyxCode() const
|
2000-08-01 17:33:32 +00:00
|
|
|
{
|
2001-04-04 20:40:16 +00:00
|
|
|
string const cmdname(getCmdName());
|
|
|
|
if (cmdname == "tableofcontents")
|
2000-08-01 17:33:32 +00:00
|
|
|
return Inset::TOC_CODE;
|
2001-05-04 10:36:36 +00:00
|
|
|
return Inset::NO_CODE;
|
2000-04-04 00:19:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
void InsetTOC::edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-04-27 07:58:56 +00:00
|
|
|
bv->owner()->getDialogs()->showTOC(this);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-01-11 16:28:22 +00:00
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
void InsetTOC::edit(BufferView * bv, bool)
|
|
|
|
{
|
|
|
|
edit(bv, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
int InsetTOC::ascii(Buffer const * buffer, ostream & os, int) const
|
2001-01-11 14:55:36 +00:00
|
|
|
{
|
2001-07-28 12:24:16 +00:00
|
|
|
os << getScreenLabel(buffer) << "\n\n";
|
2001-01-11 14:55:36 +00:00
|
|
|
|
2001-03-11 18:39:00 +00:00
|
|
|
string type;
|
2001-04-04 20:40:16 +00:00
|
|
|
string const cmdname = getCmdName();
|
2001-04-27 07:58:56 +00:00
|
|
|
if (cmdname == "tableofcontents")
|
2001-03-11 18:39:00 +00:00
|
|
|
type = "TOC";
|
2001-03-12 01:43:12 +00:00
|
|
|
Buffer::Lists const toc_list = buffer->getLists();
|
|
|
|
Buffer::Lists::const_iterator cit =
|
2001-03-11 18:39:00 +00:00
|
|
|
toc_list.find(type);
|
|
|
|
if (cit != toc_list.end()) {
|
2001-03-12 01:43:12 +00:00
|
|
|
Buffer::SingleList::const_iterator ccit = cit->second.begin();
|
|
|
|
Buffer::SingleList::const_iterator end = cit->second.end();
|
2001-03-11 18:39:00 +00:00
|
|
|
for (; ccit != end; ++ccit)
|
|
|
|
os << string(4 * ccit->depth, ' ')
|
2001-04-04 20:40:16 +00:00
|
|
|
<< ccit->str << "\n";
|
2001-03-11 18:39:00 +00:00
|
|
|
}
|
2001-05-04 10:36:36 +00:00
|
|
|
|
2001-04-04 20:40:16 +00:00
|
|
|
os << "\n";
|
2001-01-11 14:55:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-08-01 17:33:32 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
int InsetTOC::linuxdoc(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2001-04-27 07:58:56 +00:00
|
|
|
if (getCmdName() == "tableofcontents")
|
2000-08-01 17:33:32 +00:00
|
|
|
os << "<toc>";
|
2000-03-06 02:42:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
int InsetTOC::docbook(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2001-04-27 07:58:56 +00:00
|
|
|
if (getCmdName() == "tableofcontents")
|
2000-08-01 17:33:32 +00:00
|
|
|
os << "<toc></toc>";
|
2000-03-06 02:42:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|