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.
14 #include "BufferView.h"
16 #include "funcrequest.h"
18 #include "metricsinfo.h"
20 #include "frontends/LyXView.h"
21 #include "frontends/Dialogs.h"
28 InsetTOC::InsetTOC(InsetCommandParams const & p)
35 InsetCommandMailer mailer("toc", *this);
40 string const InsetTOC::getScreenLabel(Buffer const &) const
42 string const cmdname(getCmdName());
44 if (cmdname == "tableofcontents")
45 return _("Table of Contents");
46 return _("Unknown toc list");
50 InsetOld::Code InsetTOC::lyxCode() const
52 string const cmdname(getCmdName());
53 if (cmdname == "tableofcontents")
54 return InsetOld::TOC_CODE;
55 return InsetOld::NO_CODE;
59 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
61 InsetCommand::metrics(mi, dim);
62 center_indent_ = (mi.base.textwidth - dim.wid) / 2;
63 dim.wid = mi.base.textwidth;
68 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
70 InsetCommand::draw(pi, x + center_indent_, y);
74 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
78 InsetCommandMailer("toc", *this).showDialog(cmd.view());
81 return InsetCommand::localDispatch(cmd);
86 int InsetTOC::ascii(Buffer const & buffer, ostream & os, int) const
88 os << getScreenLabel(buffer) << "\n\n";
90 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
97 int InsetTOC::linuxdoc(Buffer const &, ostream & os) const
99 if (getCmdName() == "tableofcontents")
105 int InsetTOC::docbook(Buffer const &, ostream & os, bool) const
107 if (getCmdName() == "tableofcontents")