]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
160a1322af845ffe655df7daef9840a29d385e48
[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 "funcrequest.h"
16 #include "BufferView.h"
17 #include "frontends/LyXView.h"
18 #include "frontends/Dialogs.h"
19 #include "debug.h"
20 #include "toc.h"
21
22 using std::vector;
23 using std::ostream;
24
25
26 InsetTOC::InsetTOC(InsetCommandParams const & p)
27         : InsetCommand(p)
28 {}
29
30
31 // InsetTOC::InsetTOC(InsetCommandParams const & p, bool same_id)
32 //      : InsetCommand(p, same_id)
33 // {}
34
35
36 InsetTOC::~InsetTOC()
37 {
38         InsetCommandMailer mailer("toc", *this);
39         mailer.hideDialog();
40 }
41
42
43 string const InsetTOC::getScreenLabel(Buffer const *) const
44 {
45         string const cmdname(getCmdName());
46
47         if (cmdname == "tableofcontents")
48                 return _("Table of Contents");
49         return _("Unknown toc list");
50 }
51
52
53 Inset::Code InsetTOC::lyxCode() const
54 {
55         string const cmdname(getCmdName());
56         if (cmdname == "tableofcontents")
57                 return Inset::TOC_CODE;
58         return Inset::NO_CODE;
59 }
60
61
62 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
63 {
64         switch (cmd.action) {
65         case LFUN_INSET_EDIT:
66                 InsetCommandMailer("toc", *this).showDialog(cmd.view());
67                 return DISPATCHED;
68         default:
69                 return InsetCommand::localDispatch(cmd);
70         }
71 }
72
73
74 int InsetTOC::ascii(Buffer const * buffer, ostream & os, int) const
75 {
76         os << getScreenLabel(buffer) << "\n\n";
77
78         toc::asciiTocList(toc::getType(getCmdName()), buffer, os);
79
80         os << "\n";
81         return 0;
82 }
83
84
85 int InsetTOC::linuxdoc(Buffer const *, ostream & os) const
86 {
87         if (getCmdName() == "tableofcontents")
88                 os << "<toc>";
89         return 0;
90 }
91
92
93 int InsetTOC::docbook(Buffer const *, ostream & os, bool) const
94 {
95         if (getCmdName() == "tableofcontents")
96                 os << "<toc></toc>";
97         return 0;
98 }