]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTOC.cpp
83e5560cc6474821722d0b5e52216ad10d28b124
[lyx.git] / src / insets / InsetTOC.cpp
1 /**
2  * \file InsetTOC.cpp
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
11 #include <config.h>
12
13 #include "InsetTOC.h"
14
15 #include "Buffer.h"
16 #include "DispatchResult.h"
17 #include "FuncRequest.h"
18 #include "support/gettext.h"
19 #include "MetricsInfo.h"
20 #include "OutputParams.h"
21 #include "TocBackend.h"
22
23 #include <ostream>
24
25 using namespace std;
26
27 namespace lyx {
28
29
30 InsetTOC::InsetTOC(InsetCommandParams const & p)
31         : InsetCommand(p, "toc")
32 {}
33
34
35 ParamInfo const & InsetTOC::findInfo(string const & /* cmdName */)
36 {
37         static ParamInfo param_info_;
38         if (param_info_.empty()) {
39                 param_info_.add("type", ParamInfo::LATEX_REQUIRED);
40         }
41         return param_info_;
42 }
43
44
45 Inset * InsetTOC::clone() const
46 {
47         return new InsetTOC(*this);
48 }
49
50
51 docstring InsetTOC::screenLabel() const
52 {
53         if (getCmdName() == "tableofcontents")
54                 return buffer().B_("Table of Contents");
55         return _("Unknown TOC type");
56 }
57
58
59 int InsetTOC::plaintext(odocstream & os, OutputParams const &) const
60 {
61         os << screenLabel() << "\n\n";
62         buffer().tocBackend().writePlaintextTocList(getCmdName(), os);
63         return PLAINTEXT_NEWLINE;
64 }
65
66
67 int InsetTOC::docbook(odocstream & os, OutputParams const &) const
68 {
69         if (getCmdName() == "tableofcontents")
70                 os << "<toc></toc>";
71         return 0;
72 }
73
74
75 } // namespace lyx