3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
15 #include "funcrequest.h"
16 #include "BufferView.h"
17 #include "frontends/LyXView.h"
18 #include "frontends/Dialogs.h"
26 InsetTOC::InsetTOC(InsetCommandParams const & p)
33 InsetCommandMailer mailer("toc", *this);
38 string const InsetTOC::getScreenLabel(Buffer const *) const
40 string const cmdname(getCmdName());
42 if (cmdname == "tableofcontents")
43 return _("Table of Contents");
44 return _("Unknown toc list");
48 InsetOld::Code InsetTOC::lyxCode() const
50 string const cmdname(getCmdName());
51 if (cmdname == "tableofcontents")
52 return InsetOld::TOC_CODE;
53 return InsetOld::NO_CODE;
57 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
59 InsetCommand::metrics(mi, dim);
60 center_indent_ = (mi.base.textwidth - dim.wid) / 2;
61 dim.wid = mi.base.textwidth;
66 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
68 InsetCommand::draw(pi, x + center_indent_, y);
72 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
76 InsetCommandMailer("toc", *this).showDialog(cmd.view());
79 return InsetCommand::localDispatch(cmd);
84 int InsetTOC::ascii(Buffer const * buffer, ostream & os, int) const
86 os << getScreenLabel(buffer) << "\n\n";
88 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
95 int InsetTOC::linuxdoc(Buffer const *, ostream & os) const
97 if (getCmdName() == "tableofcontents")
103 int InsetTOC::docbook(Buffer const *, ostream & os, bool) const
105 if (getCmdName() == "tableofcontents")