]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
some reindentation, revert workarea xpos++, constify, remove all traces of LyXParagra...
[lyx.git] / src / insets / insettoc.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "gettext.h"
8 #include "insettoc.h"
9 #include "BufferView.h"
10 #include "LyXView.h"
11 #include "frontends/Dialogs.h"
12 #include "debug.h"
13 #include "buffer.h"
14
15 using std::vector;
16
17 string const InsetTOC::getScreenLabel() const 
18 {
19         string const cmdname(getCmdName());
20         
21         if (cmdname == "tableofcontents")
22                 return _("Table of Contents");
23         return _("Unknown toc list");
24 }
25
26
27 Inset::Code InsetTOC::LyxCode() const
28 {
29         string const cmdname(getCmdName());
30         if (cmdname == "tableofcontents")
31                 return Inset::TOC_CODE;
32         return Inset::NO_CODE;
33 }
34
35
36 void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
37 {
38         bv->owner()->getDialogs()->showTOC(this);
39 }
40
41
42 int InsetTOC::Ascii(Buffer const * buffer, std::ostream & os, int) const
43 {
44         os << getScreenLabel() << "\n\n";
45
46         string type;
47         string const cmdname = getCmdName();
48         if (cmdname == "tableofcontents")
49                 type = "TOC";
50         Buffer::Lists const toc_list = buffer->getLists();
51         Buffer::Lists::const_iterator cit =
52                 toc_list.find(type);
53         if (cit != toc_list.end()) {
54                 Buffer::SingleList::const_iterator ccit = cit->second.begin();
55                 Buffer::SingleList::const_iterator end = cit->second.end();
56                 for (; ccit != end; ++ccit)
57                         os << string(4 * ccit->depth, ' ')
58                            << ccit->str << "\n";
59         }
60
61         os << "\n";
62         return 0;
63 }
64
65
66 int InsetTOC::Linuxdoc(Buffer const *, std::ostream & os) const
67 {
68         if (getCmdName() == "tableofcontents")
69                 os << "<toc>";
70         return 0;
71 }
72
73
74 int InsetTOC::DocBook(Buffer const *, std::ostream & os) const
75 {
76         if (getCmdName() == "tableofcontents")
77                 os << "<toc></toc>";
78         return 0;
79 }