]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTOC.cpp
Embedding: display a pin at the top left corner of embedded figures
[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 #include <ostream>
24
25 using namespace std;
26
27 namespace lyx {
28
29
30 InsetTOC::InsetTOC(InsetCommandParams const & p)
31         : InsetCommand(p, "toc")
32 {}
33
34
35 CommandInfo const * InsetTOC::findInfo(string const & /* cmdName */)
36 {
37         static const char * const paramnames[] = {"type", ""};
38         static const bool isoptional[] = {false};
39         static const CommandInfo info = {1, paramnames, isoptional};
40         return &info;
41 }
42
43
44 Inset * InsetTOC::clone() const
45 {
46         return new InsetTOC(*this);
47 }
48
49
50 docstring const InsetTOC::getScreenLabel(Buffer const & buf) const
51 {
52         if (getCmdName() == "tableofcontents")
53                 return buf.B_("Table of Contents");
54         return _("Unknown TOC type");
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         return PLAINTEXT_NEWLINE;
66 }
67
68
69 int InsetTOC::docbook(Buffer const &, odocstream & os,
70                       OutputParams const &) const
71 {
72         if (getCmdName() == "tableofcontents")
73                 os << "<toc></toc>";
74         return 0;
75 }
76
77
78 } // namespace lyx