4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
16 #include "InsetCollapsible.h"
17 #include "InsetCommand.h"
24 class InsetIndexParams {
32 explicit InsetIndexParams(docstring const & b = docstring())
33 : index(b), range(None), pagefmt("default") {}
35 void write(std::ostream & os) const;
37 void read(Lexer & lex);
47 /** Used to insert index labels
49 class InsetIndex : public InsetCollapsible {
52 InsetIndex(Buffer *, InsetIndexParams const &);
54 static std::string params2string(InsetIndexParams const &);
56 static void string2params(std::string const &, InsetIndexParams &);
58 const InsetIndexParams& params() const { return params_; }
60 int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
62 InsetIndex const * asInsetIndex() const override { return this; }
65 bool hasSettings() const override;
67 InsetCode lyxCode() const override { return INDEX_CODE; }
69 docstring layoutName() const override { return from_ascii("Index"); }
71 ColorCode labelColor() const override;
73 void write(std::ostream & os) const override;
75 void read(Lexer & lex) override;
77 void docbook(XMLStream &, OutputParams const &) const override;
79 docstring xhtml(XMLStream &, OutputParams const &) const override;
81 void latex(otexstream &, OutputParams const &) const override;
83 void processLatexSorting(otexstream &, OutputParams const &,
84 docstring const, docstring const) const;
86 bool showInsetDialog(BufferView *) const override;
88 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
90 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
91 /// should paragraph indentation be omitted in any case?
92 bool neverIndent() const override { return true; }
94 void addToToc(DocIterator const & di, bool output_active,
95 UpdateType utype, TocBackend & backend) const override;
97 docstring toolTip(BufferView const & bv, int x, int y) const override;
99 docstring const buttonLabel(BufferView const & bv) const override;
100 /// Updates needed features for this inset.
101 void validate(LaTeXFeatures & features) const override;
103 void getSortkey(otexstream &, OutputParams const &) const;
105 docstring getSortkeyAsText(OutputParams const &) const;
107 void emptySubentriesWarning(docstring const & mainentry) const;
109 void getSubentries(otexstream &, OutputParams const &, docstring const &) const;
111 std::vector<docstring> getSubentriesAsText(OutputParams const &,
112 bool const asLabel = false) const;
114 docstring getMainSubentryAsText(OutputParams const & runparams) const;
116 void getSeeRefs(otexstream &, OutputParams const &) const;
118 docstring getSeeAsText(OutputParams const & runparams,
119 bool const asLabel = false) const;
121 std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams,
122 bool const asLabel = false) const;
124 bool hasSubentries() const;
126 bool hasSeeRef() const;
128 bool hasSortKey() const;
130 bool macrosPossible(std::string const type) const;
132 std::string contextMenuName() const override;
134 std::string contextMenu(BufferView const &, int, int) const override;
136 Inset * clone() const override { return new InsetIndex(*this); }
137 /// Is the content of this inset part of the immediate text sequence?
138 bool isPartOfTextSequence() const override { return false; }
140 bool insetAllowed(InsetCode code) const override;
143 friend class InsetIndexParams;
145 friend class IndexEntry;
147 InsetIndexParams params_;
151 class InsetPrintIndex : public InsetCommand {
154 InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
156 /// \name Public functions inherited from Inset class
159 InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
161 void latex(otexstream &, OutputParams const &) const override;
163 docstring xhtml(XMLStream &, OutputParams const &) const override;
165 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
167 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
169 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
171 std::string contextMenuName() const override;
172 /// Updates needed features for this inset.
173 void validate(LaTeXFeatures & features) const override;
175 bool hasSettings() const override;
177 int rowFlags() const override { return Display; }
180 /// \name Static public methods obligated for InsetCommand derived classes
183 static ParamInfo const & findInfo(std::string const &);
185 static std::string defaultCommand() { return "printindex"; }
187 static bool isCompatibleCommand(std::string const & s);
191 /// \name Private functions inherited from Inset class
194 Inset * clone() const override { return new InsetPrintIndex(*this); }
197 /// \name Private functions inherited from InsetCommand class
200 docstring screenLabel() const override;