]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
277212db00dbbc2996fe1540c490530b2e2a3010
[lyx.git] / src / insets / insettoc.C
1 /**
2  * \file insettoc.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS
9  */
10 #include <config.h>
11
12
13 #include "gettext.h"
14 #include "insettoc.h"
15 #include "BufferView.h"
16 #include "frontends/LyXView.h"
17 #include "frontends/Dialogs.h"
18 #include "debug.h"
19 #include "toc.h"
20
21 using std::vector;
22 using std::ostream;
23
24
25 string const InsetTOC::getScreenLabel(Buffer const *) const
26 {
27         string const cmdname(getCmdName());
28
29         if (cmdname == "tableofcontents")
30                 return _("Table of Contents");
31         return _("Unknown toc list");
32 }
33
34
35 Inset::Code InsetTOC::lyxCode() const
36 {
37         string const cmdname(getCmdName());
38         if (cmdname == "tableofcontents")
39                 return Inset::TOC_CODE;
40         return Inset::NO_CODE;
41 }
42
43
44 void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state)
45 {
46         bv->owner()->getDialogs().showTOC(this);
47 }
48
49
50 void InsetTOC::edit(BufferView * bv, bool)
51 {
52         edit(bv, 0, 0, mouse_button::none);
53 }
54
55
56 int InsetTOC::ascii(Buffer const * buffer, ostream & os, int) const
57 {
58         os << getScreenLabel(buffer) << "\n\n";
59
60         toc::asciiTocList(toc::getType(getCmdName()), buffer, os);
61
62         os << "\n";
63         return 0;
64 }
65
66
67 int InsetTOC::linuxdoc(Buffer const *, ostream & os) const
68 {
69         if (getCmdName() == "tableofcontents")
70                 os << "<toc>";
71         return 0;
72 }
73
74
75 int InsetTOC::docbook(Buffer const *, ostream & os, bool) const
76 {
77         if (getCmdName() == "tableofcontents")
78                 os << "<toc></toc>";
79         return 0;
80 }