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