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/docstream.h"
24 #include "support/gettext.h"
25 #include "support/lstrings.h"
30 using namespace lyx::support;
34 /////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////
41 InsetIndex::InsetIndex(Buffer const & buf)
42 : InsetCollapsable(buf)
46 int InsetIndex::latex(odocstream & os,
47 OutputParams const & runparams) const
52 InsetText::latex(ods, runparams);
53 // correctly sort macros and formatted strings
54 // if we do find a command, prepend a plain text
55 // version of the content to get sorting right,
56 // e.g. \index{LyX@\LyX}, \index{text@\textbf{text}}
57 // Don't do that if the user entered '@' himself, though.
58 if (contains(ods.str(), '\\') && !contains(ods.str(), '@')) {
59 if (InsetText::plaintext(os, runparams) > 0)
62 int i = InsetText::latex(os, runparams);
68 int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
70 os << "<indexterm><primary>";
71 int const i = InsetText::docbook(os, runparams);
72 os << "</primary></indexterm>";
77 void InsetIndex::write(ostream & os) const
79 os << to_utf8(name()) << "\n";
80 InsetCollapsable::write(os);
84 void InsetIndex::addToToc(ParConstIterator const & cpit) const
86 ParConstIterator pit = cpit;
89 Toc & toc = buffer().tocBackend().toc("index");
91 str = getNewLabel(str);
92 toc.push_back(TocItem(pit, 0, str));
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;