]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTOC.cpp
InsetListings: change the interface of diaplay function and allow AlignLeft. 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 std::auto_ptr<Inset> InsetTOC::doClone() const
38 {
39         return std::auto_ptr<Inset>(new InsetTOC(*this));
40 }
41
42
43 docstring const InsetTOC::getScreenLabel(Buffer const & buf) const
44 {
45         if (getCmdName() == "tableofcontents")
46                 return buf.B_("Table of Contents");
47         return _("Unknown TOC type");
48 }
49
50
51 Inset::Code InsetTOC::lyxCode() const
52 {
53         if (getCmdName() == "tableofcontents")
54                 return Inset::TOC_CODE;
55         return Inset::NO_CODE;
56 }
57
58
59 int InsetTOC::plaintext(Buffer const & buffer, odocstream & os,
60                         OutputParams const &) const
61 {
62         os << getScreenLabel(buffer) << "\n\n";
63
64         buffer.tocBackend().writePlaintextTocList(getCmdName(), os);
65
66         return PLAINTEXT_NEWLINE;
67 }
68
69
70 int InsetTOC::docbook(Buffer const &, odocstream & os,
71                       OutputParams const &) const
72 {
73         if (getCmdName() == "tableofcontents")
74                 os << "<toc></toc>";
75         return 0;
76 }
77
78
79 } // namespace lyx