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 getSubentries(otexstream &, OutputParams const &) const;
107 std::vector<docstring> getSubentriesAsText(OutputParams const &,
108 bool const asLabel = false) const;
110 docstring getMainSubentryAsText(OutputParams const & runparams) const;
112 void getSeeRefs(otexstream &, OutputParams const &) const;
114 docstring getSeeAsText(OutputParams const & runparams) const;
116 std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams) const;
118 bool hasSubentries() const;
120 bool hasSeeRef() const;
122 bool hasSortKey() const;
124 bool macrosPossible(std::string const type) const;
126 std::string contextMenuName() const override;
128 std::string contextMenu(BufferView const &, int, int) const override;
130 Inset * clone() const override { return new InsetIndex(*this); }
131 /// Is the content of this inset part of the immediate text sequence?
132 bool isPartOfTextSequence() const override { return false; }
134 bool insetAllowed(InsetCode code) const override;
137 friend class InsetIndexParams;
139 friend class IndexEntry;
141 InsetIndexParams params_;
145 class InsetPrintIndex : public InsetCommand {
148 InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
150 /// \name Public functions inherited from Inset class
153 InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
155 void latex(otexstream &, OutputParams const &) const override;
157 docstring xhtml(XMLStream &, OutputParams const &) const override;
159 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
161 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
163 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
165 std::string contextMenuName() const override;
166 /// Updates needed features for this inset.
167 void validate(LaTeXFeatures & features) const override;
169 bool hasSettings() const override;
171 int rowFlags() const override { return Display; }
174 /// \name Static public methods obligated for InsetCommand derived classes
177 static ParamInfo const & findInfo(std::string const &);
179 static std::string defaultCommand() { return "printindex"; }
181 static bool isCompatibleCommand(std::string const & s);
185 /// \name Private functions inherited from Inset class
188 Inset * clone() const override { return new InsetPrintIndex(*this); }
191 /// \name Private functions inherited from InsetCommand class
194 docstring screenLabel() const override;