]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTOC.cpp
ae65f1be9eb62c2b53fc7843f9a4beb0ddf4c49b
[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 using namespace std;
24
25 namespace lyx {
26
27
28 InsetTOC::InsetTOC(InsetCommandParams const & p)
29         : InsetCommand(p, "toc")
30 {}
31
32
33 ParamInfo const & InsetTOC::findInfo(string const & /* cmdName */)
34 {
35         static ParamInfo param_info_;
36         if (param_info_.empty()) {
37                 param_info_.add("type", ParamInfo::LATEX_REQUIRED);
38         }
39         return param_info_;
40 }
41
42
43 docstring InsetTOC::screenLabel() const
44 {
45         if (getCmdName() == "tableofcontents")
46                 return buffer().B_("Table of Contents");
47         return _("Unknown TOC type");
48 }
49
50
51 int InsetTOC::plaintext(odocstream & os, OutputParams const &) const
52 {
53         os << screenLabel() << "\n\n";
54         buffer().tocBackend().writePlaintextTocList(getCmdName(), os);
55         return PLAINTEXT_NEWLINE;
56 }
57
58
59 int InsetTOC::docbook(odocstream & os, OutputParams const &) const
60 {
61         if (getCmdName() == "tableofcontents")
62                 os << "<toc></toc>";
63         return 0;
64 }
65
66
67 } // namespace lyx