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.
12 #include "InsetIndex.h"
15 #include "DispatchResult.h"
16 #include "FuncRequest.h"
17 #include "FuncStatus.h"
18 #include "LaTeXFeatures.h"
19 #include "MetricsInfo.h"
21 #include "TocBackend.h"
23 #include "support/gettext.h"
31 /////////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////
38 InsetIndex::InsetIndex(Buffer const & buf)
39 : InsetCollapsable(buf)
43 int InsetIndex::latex(odocstream & os,
44 OutputParams const & runparams) const
48 if (hasFontChanges()) {
49 InsetText::plaintext(os, runparams);
52 int i = InsetText::latex(os, runparams);
58 int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
60 os << "<indexterm><primary>";
61 int const i = InsetText::docbook(os, runparams);
62 os << "</primary></indexterm>";
67 void InsetIndex::write(ostream & os) const
69 os << to_utf8(name()) << "\n";
70 InsetCollapsable::write(os);
74 void InsetIndex::addToToc(ParConstIterator const & cpit) const
76 ParConstIterator pit = cpit;
79 Toc & toc = buffer().tocBackend().toc("index");
81 str = getNewLabel(str);
82 toc.push_back(TocItem(pit, 0, str));
86 bool InsetIndex::hasFontChanges() const
88 // we only have one par
89 Paragraph par = paragraphs().back();
90 FontSpan const font_span = par.fontSpan(0);
91 Font firstfont = par.getFirstFontSettings(buffer().params());
92 return (firstfont.fontInfo() != inherit_font || par.size() > font_span.last + 1);
96 /////////////////////////////////////////////////////////////////////
100 ///////////////////////////////////////////////////////////////////////
102 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
103 : InsetCommand(p, string())
107 ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
109 static ParamInfo param_info_;
110 if (param_info_.empty())
111 param_info_.add("name", ParamInfo::LATEX_REQUIRED);
116 docstring InsetPrintIndex::screenLabel() const
122 void InsetPrintIndex::validate(LaTeXFeatures & features) const
124 features.require("makeidx");
128 InsetCode InsetPrintIndex::lyxCode() const
130 return INDEX_PRINT_CODE;