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"
|
2000-08-01 17:33:32 +00:00
|
|
|
#include "LyXView.h"
|
|
|
|
#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
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
2001-03-15 10:31:00 +00:00
|
|
|
using std::vector;
|
2001-01-11 14:55:36 +00:00
|
|
|
using std::endl;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetTOC::getScreenLabel() const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
string cmdname( getCmdName() );
|
2000-11-04 10:00:12 +00:00
|
|
|
if (cmdname == "tableofcontents" )
|
2000-08-01 17:33:32 +00:00
|
|
|
return _("Table of Contents");
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (cmdname == "listofalgorithms" )
|
2000-08-01 17:33:32 +00:00
|
|
|
return _("List of Algorithms");
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (cmdname == "listoffigures" )
|
2000-08-01 17:33:32 +00:00
|
|
|
return _("List of Figures");
|
|
|
|
else
|
|
|
|
return _("List of Tables");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Inset::Code InsetTOC::LyxCode() const
|
|
|
|
{
|
|
|
|
string cmdname( getCmdName() );
|
2000-11-04 10:00:12 +00:00
|
|
|
if (cmdname == "tableofcontents" )
|
2000-08-01 17:33:32 +00:00
|
|
|
return Inset::TOC_CODE;
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (cmdname == "listofalgorithms" )
|
2000-08-01 17:33:32 +00:00
|
|
|
return Inset::LOA_CODE;
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (cmdname == "listoffigures" )
|
2000-08-01 17:33:32 +00:00
|
|
|
return Inset::LOF_CODE;
|
|
|
|
else
|
|
|
|
return Inset::LOT_CODE;
|
2000-04-04 00:19:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
bv->owner()->getDialogs()->showTOC( this );
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-01-11 16:28:22 +00:00
|
|
|
|
2001-01-11 14:55:36 +00:00
|
|
|
int InsetTOC::Ascii(Buffer const * buffer, ostream & os, int) const
|
|
|
|
{
|
|
|
|
os << getScreenLabel() << endl << endl;
|
|
|
|
|
2001-03-11 18:39:00 +00:00
|
|
|
#if 0
|
2001-01-11 14:55:36 +00:00
|
|
|
Buffer::TocType type;
|
|
|
|
string cmdname = getCmdName();
|
|
|
|
if (cmdname == "tableofcontents" )
|
|
|
|
type = Buffer::TOC_TOC;
|
|
|
|
else if (cmdname == "listofalgorithms" )
|
|
|
|
type = Buffer::TOC_LOA;
|
|
|
|
else if (cmdname == "listoffigures" )
|
|
|
|
type = Buffer::TOC_LOF;
|
|
|
|
else
|
|
|
|
type = Buffer::TOC_LOT;
|
|
|
|
|
|
|
|
vector<vector<Buffer::TocItem> > const toc_list =
|
|
|
|
buffer->getTocList();
|
|
|
|
vector<Buffer::TocItem> const & toc = toc_list[type];
|
|
|
|
for (vector<Buffer::TocItem>::const_iterator it = toc.begin();
|
|
|
|
it != toc.end(); ++it)
|
|
|
|
os << string(4 * it->depth, ' ') << it->str << endl;
|
2001-03-11 18:39:00 +00:00
|
|
|
#else
|
|
|
|
#warning Fix Me! (Lgb)
|
|
|
|
string type;
|
|
|
|
string cmdname = getCmdName();
|
|
|
|
if (cmdname == "tableofcontents" )
|
|
|
|
type = "TOC";
|
|
|
|
else if (cmdname == "listofalgorithms" )
|
|
|
|
type = "LOA";
|
|
|
|
else if (cmdname == "listoffigures" )
|
|
|
|
type = "LOF";
|
|
|
|
else
|
|
|
|
type = "LOT";
|
2001-01-11 14:55:36 +00:00
|
|
|
|
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, ' ')
|
|
|
|
<< ccit->str << endl;
|
|
|
|
}
|
|
|
|
#endif
|
2001-01-11 14:55:36 +00:00
|
|
|
os << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-08-01 17:33:32 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
int InsetTOC::Linuxdoc(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2000-11-04 10:00:12 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
int InsetTOC::DocBook(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2000-11-04 10:00:12 +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;
|
|
|
|
}
|