]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insettoc.C
1 /**
2  * \file insettoc.C
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 "TocBackend.h"
21
22 #include "support/std_ostream.h"
23
24
25 namespace lyx {
26
27 using std::string;
28 using std::ostream;
29
30
31 InsetTOC::InsetTOC(InsetCommandParams const & p)
32         : InsetCommand(p, "toc")
33 {}
34
35
36 std::auto_ptr<InsetBase> InsetTOC::doClone() const
37 {
38         return std::auto_ptr<InsetBase>(new InsetTOC(*this));
39 }
40
41
42 docstring const InsetTOC::getScreenLabel(Buffer const &) const
43 {
44         if (getCmdName() == "tableofcontents")
45                 return _("Table of Contents");
46         return _("Unknown toc list");
47 }
48
49
50 InsetBase::Code InsetTOC::lyxCode() const
51 {
52         if (getCmdName() == "tableofcontents")
53                 return InsetBase::TOC_CODE;
54         return InsetBase::NO_CODE;
55 }
56
57
58 int InsetTOC::plaintext(Buffer const & buffer, odocstream & os,
59                     OutputParams const &) const
60 {
61         os << getScreenLabel(buffer) << "\n\n";
62
63         buffer.tocBackend().writePlaintextTocList(getCmdName(), os);
64
65         os << "\n";
66         return 0;
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