X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetIndex.cpp;h=e46e6cea8016168a921ddad2c26523f53ba7f0a1;hb=2c357c1d23b7b83839a9beb8225d4f1ae4f793b4;hp=11876270ce8d0b119365617bfd926ae10198e618;hpb=f7b1c86393d890d5d473279d88e26bb78f8c1275;p=lyx.git diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 11876270ce..e46e6cea80 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -11,28 +11,27 @@ #include "InsetIndex.h" +#include "Buffer.h" #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "gettext.h" #include "LaTeXFeatures.h" #include "MetricsInfo.h" #include "sgml.h" +#include "TocBackend.h" -#include "support/std_ostream.h" +#include "support/gettext.h" +#include -namespace lyx { +using namespace std; -using std::string; -using std::ostream; +namespace lyx { InsetIndex::InsetIndex(BufferParams const & bp) : InsetCollapsable(bp) -{ - setLayout(bp); -} +{} InsetIndex::InsetIndex(InsetIndex const & in) @@ -50,74 +49,46 @@ int InsetIndex::docbook(Buffer const & buf, odocstream & os, } -InsetCode InsetIndex::lyxCode() const -{ - return INDEX_CODE; -} - - Inset * InsetIndex::clone() const { return new InsetIndex(*this); } -void InsetIndex::write(Buffer const & buf, std::ostream & os) const +void InsetIndex::write(Buffer const & buf, ostream & os) const { os << to_utf8(name()) << "\n"; InsetCollapsable::write(buf, os); } -void InsetIndex::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetIndex::addToToc(Buffer const & buf, + ParConstIterator const & cpit) const { - Font tmpfont = mi.base.font; - getDrawFont(mi.base.font); - mi.base.font.realize(tmpfont); - InsetCollapsable::metrics(mi, dim); - mi.base.font = tmpfont; -} - + ParConstIterator pit = cpit; + pit.push_back(*this); -void InsetIndex::draw(PainterInfo & pi, int x, int y) const -{ - Font tmpfont = pi.base.font; - getDrawFont(pi.base.font); - pi.base.font.realize(tmpfont); - InsetCollapsable::draw(pi, x, y); - pi.base.font = tmpfont; + Toc & toc = buf.tocBackend().toc("index"); + docstring str; + str = getNewLabel(str); + toc.push_back(TocItem(pit, 0, str)); } -void InsetIndex::getDrawFont(Font & font) const -{ - font = Font(Font::ALL_INHERIT); - font.realize(layout_.font); -} +InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p) + : InsetCommand(p, string()) +{} -bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd, - FuncStatus & status) const +CommandInfo const * InsetPrintIndex::findInfo(string const & /* cmdName */) { - switch (cmd.action) { - // paragraph breaks not allowed - case LFUN_BREAK_PARAGRAPH: - case LFUN_BREAK_PARAGRAPH_SKIP: - status.enabled(false); - return true; - - default: - return InsetCollapsable::getStatus(cur, cmd, status); - } + static const char * const paramnames[] = {"name", ""}; + static const bool isoptional[] = {false}; + static const CommandInfo info = {1, paramnames, isoptional}; + return &info; } - -InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p) - : InsetCommand(p, string()) -{} - - docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const { return _("Index"); @@ -135,5 +106,4 @@ InsetCode InsetPrintIndex::lyxCode() const return INDEX_PRINT_CODE; } - } // namespace lyx