]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
* inset.h:
[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 "dispatchresult.h"
16 #include "funcrequest.h"
17 #include "gettext.h"
18 #include "metricsinfo.h"
19 #include "toc.h"
20
21 #include "support/std_ostream.h"
22
23 using std::string;
24 using std::ostream;
25
26
27
28 InsetTOC::InsetTOC(InsetCommandParams const & p)
29         : InsetCommand(p)
30 {}
31
32
33 InsetTOC::~InsetTOC()
34 {
35         InsetCommandMailer("toc", *this).hideDialog();
36 }
37
38
39 std::auto_ptr<InsetBase> InsetTOC::clone() const
40 {
41         return std::auto_ptr<InsetBase>(new InsetTOC(*this));
42 }
43
44
45 string const InsetTOC::getScreenLabel(Buffer const &) const
46 {
47         if (getCmdName() == "tableofcontents")
48                 return _("Table of Contents");
49         return _("Unknown toc list");
50 }
51
52
53 InsetOld::Code InsetTOC::lyxCode() const
54 {
55         if (getCmdName() == "tableofcontents")
56                 return InsetOld::TOC_CODE;
57         return InsetOld::NO_CODE;
58 }
59
60
61 DispatchResult
62 InsetTOC::priv_dispatch(FuncRequest const & cmd,
63                         idx_type & idx, pos_type & pos)
64 {
65         switch (cmd.action) {
66         case LFUN_MOUSE_RELEASE:
67         case LFUN_INSET_DIALOG_SHOW:
68                 InsetCommandMailer("toc", *this).showDialog(cmd.view());
69                 return DispatchResult(true, true);
70
71         default:
72                 return InsetCommand::priv_dispatch(cmd, idx, pos);
73         }
74 }
75
76
77 int InsetTOC::plaintext(Buffer const & buffer, ostream & os,
78                     OutputParams const &) const
79 {
80         os << getScreenLabel(buffer) << "\n\n";
81
82         lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
83
84         os << "\n";
85         return 0;
86 }
87
88
89 int InsetTOC::linuxdoc(Buffer const &, ostream & os,
90                        OutputParams const &) const
91 {
92         if (getCmdName() == "tableofcontents")
93                 os << "<toc>";
94         return 0;
95 }
96
97
98 int InsetTOC::docbook(Buffer const &, ostream & os,
99                       OutputParams const &) const
100 {
101         if (getCmdName() == "tableofcontents")
102                 os << "<toc></toc>";
103         return 0;
104 }