/** * \file InsetIndex.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. */ #include #include "InsetIndex.h" #include "Buffer.h" #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" #include "LaTeXFeatures.h" #include "MetricsInfo.h" #include "sgml.h" #include "TocBackend.h" #include "support/gettext.h" #include using namespace std; namespace lyx { ///////////////////////////////////////////////////////////////////// // // InsetIndex // /////////////////////////////////////////////////////////////////////// InsetIndex::InsetIndex(Buffer const & buf) : InsetCollapsable(buf) {} int InsetIndex::latex(odocstream & os, OutputParams const & runparams) const { os << "\\index"; os << '{'; if (hasFontChanges()) { InsetText::plaintext(os, runparams); os << '@'; } int i = InsetText::latex(os, runparams); os << '}'; return i; } int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const { os << ""; int const i = InsetText::docbook(os, runparams); os << ""; return i; } void InsetIndex::write(ostream & os) const { os << to_utf8(name()) << "\n"; InsetCollapsable::write(os); } void InsetIndex::addToToc(ParConstIterator const & cpit) const { ParConstIterator pit = cpit; pit.push_back(*this); Toc & toc = buffer().tocBackend().toc("index"); docstring str; str = getNewLabel(str); toc.push_back(TocItem(pit, 0, str)); } bool InsetIndex::hasFontChanges() const { // we only have one par Paragraph par = paragraphs().back(); FontSpan const font_span = par.fontSpan(0); Font firstfont = par.getFirstFontSettings(buffer().params()); return (firstfont.fontInfo() != inherit_font || par.size() > font_span.last + 1); } ///////////////////////////////////////////////////////////////////// // // InsetPrintIndex // /////////////////////////////////////////////////////////////////////// InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p) : InsetCommand(p, string()) {} ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */) { static ParamInfo param_info_; if (param_info_.empty()) param_info_.add("name", ParamInfo::LATEX_REQUIRED); return param_info_; } docstring InsetPrintIndex::screenLabel() const { return _("Index"); } void InsetPrintIndex::validate(LaTeXFeatures & features) const { features.require("makeidx"); } InsetCode InsetPrintIndex::lyxCode() const { return INDEX_PRINT_CODE; } } // namespace lyx