]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
put namespace toc inside namespace lxy
[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()
32 {
33         InsetCommandMailer mailer("toc", *this);
34         mailer.hideDialog();
35 }
36
37
38 string const InsetTOC::getScreenLabel(Buffer const *) const
39 {
40         string const cmdname(getCmdName());
41
42         if (cmdname == "tableofcontents")
43                 return _("Table of Contents");
44         return _("Unknown toc list");
45 }
46
47
48 InsetOld::Code InsetTOC::lyxCode() const
49 {
50         string const cmdname(getCmdName());
51         if (cmdname == "tableofcontents")
52                 return InsetOld::TOC_CODE;
53         return InsetOld::NO_CODE;
54 }
55
56
57 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
58 {
59         switch (cmd.action) {
60         case LFUN_INSET_EDIT:
61                 InsetCommandMailer("toc", *this).showDialog(cmd.view());
62                 return DISPATCHED;
63         default:
64                 return InsetCommand::localDispatch(cmd);
65         }
66 }
67
68
69 int InsetTOC::ascii(Buffer const * buffer, ostream & os, int) const
70 {
71         os << getScreenLabel(buffer) << "\n\n";
72
73         lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
74
75         os << "\n";
76         return 0;
77 }
78
79
80 int InsetTOC::linuxdoc(Buffer const *, ostream & os) const
81 {
82         if (getCmdName() == "tableofcontents")
83                 os << "<toc>";
84         return 0;
85 }
86
87
88 int InsetTOC::docbook(Buffer const *, ostream & os, bool) const
89 {
90         if (getCmdName() == "tableofcontents")
91                 os << "<toc></toc>";
92         return 0;
93 }