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; }
63 bool hasSettings() const override;
65 InsetCode lyxCode() const override { return INDEX_CODE; }
67 docstring layoutName() const override { return from_ascii("Index"); }
69 ColorCode labelColor() const override;
71 void write(std::ostream & os) const override;
73 void read(Lexer & lex) override;
75 void docbook(XMLStream &, OutputParams const &) const override;
77 docstring xhtml(XMLStream &, OutputParams const &) const override;
79 void latex(otexstream &, OutputParams const &) const override;
81 void processLatexSorting(otexstream &, OutputParams const &,
82 docstring const, docstring const) const;
84 bool showInsetDialog(BufferView *) const override;
86 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
88 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
89 /// should paragraph indentation be omitted in any case?
90 bool neverIndent() const override { return true; }
92 void addToToc(DocIterator const & di, bool output_active,
93 UpdateType utype, TocBackend & backend) const override;
95 docstring toolTip(BufferView const & bv, int x, int y) const override;
97 docstring const buttonLabel(BufferView const & bv) const override;
98 /// Updates needed features for this inset.
99 void validate(LaTeXFeatures & features) const override;
101 void getSortkey(otexstream &, OutputParams const &) const;
103 docstring getSortkeyAsText(OutputParams const &) const;
105 void emptySubentriesWarning(docstring const & mainentry) const;
107 void getSubentries(otexstream &, OutputParams const &, docstring const &) const;
109 std::vector<docstring> getSubentriesAsText(OutputParams const &,
110 bool const asLabel = false) const;
112 docstring getMainSubentryAsText(OutputParams const & runparams) const;
114 void getSeeRefs(otexstream &, OutputParams const &) const;
116 docstring getSeeAsText(OutputParams const & runparams,
117 bool const asLabel = false) const;
119 std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams,
120 bool const asLabel = false) const;
122 bool hasSubentries() const;
124 bool hasSeeRef() const;
126 bool hasSortKey() const;
128 bool macrosPossible(std::string const type) const;
130 std::string contextMenuName() const override;
132 std::string contextMenu(BufferView const &, int, int) const override;
134 Inset * clone() const override { return new InsetIndex(*this); }
135 /// Is the content of this inset part of the immediate text sequence?
136 bool isPartOfTextSequence() const override { return false; }
138 bool insetAllowed(InsetCode code) const override;
141 friend class InsetIndexParams;
143 friend class IndexEntry;
145 InsetIndexParams params_;
149 class InsetPrintIndex : public InsetCommand {
152 InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
154 /// \name Public functions inherited from Inset class
157 InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
159 void latex(otexstream &, OutputParams const &) const override;
161 docstring xhtml(XMLStream &, OutputParams const &) const override;
163 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
165 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
167 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
169 std::string contextMenuName() const override;
170 /// Updates needed features for this inset.
171 void validate(LaTeXFeatures & features) const override;
173 bool hasSettings() const override;
175 int rowFlags() const override { return Display; }
178 /// \name Static public methods obligated for InsetCommand derived classes
181 static ParamInfo const & findInfo(std::string const &);
183 static std::string defaultCommand() { return "printindex"; }
185 static bool isCompatibleCommand(std::string const & s);
189 /// \name Private functions inherited from Inset class
192 Inset * clone() const override { return new InsetPrintIndex(*this); }
195 /// \name Private functions inherited from InsetCommand class
198 docstring screenLabel() const override;