]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTOC.cpp
Further cleanup of collapsable insets. The layouts are now properly read and applied.
[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 "gettext.h"
19 #include "MetricsInfo.h"
20 #include "OutputParams.h"
21 #include "TocBackend.h"
22
23 #include "support/std_ostream.h"
24
25
26 namespace lyx {
27
28 using std::string;
29 using std::ostream;
30
31
32 InsetTOC::InsetTOC(InsetCommandParams const & p)
33         : InsetCommand(p, "toc")
34 {}
35
36
37 CommandInfo const * InsetTOC::findInfo(std::string const & /* cmdName */)
38 {
39         static const char * const paramnames[] = {"type", ""};
40         static const bool isoptional[] = {false};
41         static const CommandInfo info = {1, paramnames, isoptional};
42         return &info;
43 }
44
45
46 Inset * InsetTOC::clone() const
47 {
48         return new InsetTOC(*this);
49 }
50
51
52 docstring const InsetTOC::getScreenLabel(Buffer const & buf) const
53 {
54         if (getCmdName() == "tableofcontents")
55                 return buf.B_("Table of Contents");
56         return _("Unknown TOC type");
57 }
58
59
60 int InsetTOC::plaintext(Buffer const & buffer, odocstream & os,
61                         OutputParams const &) const
62 {
63         os << getScreenLabel(buffer) << "\n\n";
64
65         buffer.tocBackend().writePlaintextTocList(getCmdName(), os);
66
67         return PLAINTEXT_NEWLINE;
68 }
69
70
71 int InsetTOC::docbook(Buffer const &, odocstream & os,
72                       OutputParams const &) const
73 {
74         if (getCmdName() == "tableofcontents")
75                 os << "<toc></toc>";
76         return 0;
77 }
78
79
80 } // namespace lyx