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 &);
59 bool hasSettings() const override;
61 InsetCode lyxCode() const override { return INDEX_CODE; }
63 docstring layoutName() const override { return from_ascii("Index"); }
65 ColorCode labelColor() const override;
67 void write(std::ostream & os) const override;
69 void read(Lexer & lex) override;
71 void docbook(XMLStream &, OutputParams const &) const override;
73 docstring xhtml(XMLStream &, OutputParams const &) const override;
75 void latex(otexstream &, OutputParams const &) const override;
77 void processLatexSorting(otexstream &, OutputParams const &,
78 docstring const, docstring const) const;
80 bool showInsetDialog(BufferView *) const override;
82 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
84 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
85 /// should paragraph indentation be omitted in any case?
86 bool neverIndent() const override { return true; }
88 void addToToc(DocIterator const & di, bool output_active,
89 UpdateType utype, TocBackend & backend) const override;
91 docstring toolTip(BufferView const & bv, int x, int y) const override;
93 docstring const buttonLabel(BufferView const & bv) const override;
94 /// Updates needed features for this inset.
95 void validate(LaTeXFeatures & features) const override;
97 void getSortkey(otexstream &, OutputParams const &) const;
99 docstring getSortkeyAsText(OutputParams const &) const;
101 void getSubentries(otexstream &, OutputParams const &) const;
103 std::vector<docstring> getSubentriesAsText(OutputParams const &) const;
105 docstring getMainSubentryAsText(OutputParams const & runparams) const;
107 void getSeeRefs(otexstream &, OutputParams const &) const;
109 docstring getSeeAsText(OutputParams const & runparams) const;
111 std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams) const;
113 bool hasSubentries() const;
115 bool hasSeeRef() const;
117 bool hasSortKey() const;
119 bool macrosPossible(std::string const type) const;
121 std::string contextMenuName() const override;
123 std::string contextMenu(BufferView const &, int, int) const override;
125 Inset * clone() const override { return new InsetIndex(*this); }
126 /// Is the content of this inset part of the immediate text sequence?
127 bool isPartOfTextSequence() const override { return false; }
129 bool insetAllowed(InsetCode code) const override;
132 friend class InsetIndexParams;
134 friend class IndexEntry;
136 InsetIndexParams params_;
140 class InsetPrintIndex : public InsetCommand {
143 InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
145 /// \name Public functions inherited from Inset class
148 InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
150 void latex(otexstream &, OutputParams const &) const override;
152 docstring xhtml(XMLStream &, OutputParams const &) const override;
154 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
156 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
158 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
160 std::string contextMenuName() const override;
161 /// Updates needed features for this inset.
162 void validate(LaTeXFeatures & features) const override;
164 bool hasSettings() const override;
166 int rowFlags() const override { return Display; }
169 /// \name Static public methods obligated for InsetCommand derived classes
172 static ParamInfo const & findInfo(std::string const &);
174 static std::string defaultCommand() { return "printindex"; }
176 static bool isCompatibleCommand(std::string const & s);
180 /// \name Private functions inherited from Inset class
183 Inset * clone() const override { return new InsetPrintIndex(*this); }
186 /// \name Private functions inherited from InsetCommand class
189 docstring screenLabel() const override;