]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndex.h
b3fe2713d9e66d6079dcb340a303061a752ce4a1
[lyx.git] / src / insets / InsetIndex.h
1 // -*- C++ -*-
2 /**
3  * \file InsetIndex.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_INDEX_H
13 #define INSET_INDEX_H
14
15
16 #include "InsetCollapsible.h"
17 #include "InsetCommand.h"
18
19
20 namespace lyx {
21
22 class IndexEntry;
23
24 class InsetIndexParams {
25 public:
26         enum PageRange {
27                 None,
28                 Start,
29                 End
30         };
31         ///
32         explicit InsetIndexParams(docstring const & b = docstring())
33                 : index(b), range(None), pagefmt("default") {}
34         ///
35         void write(std::ostream & os) const;
36         ///
37         void read(Lexer & lex);
38         ///
39         docstring index;
40         ///
41         PageRange range;
42         ///
43         std::string pagefmt;
44 };
45
46
47 /** Used to insert index labels
48   */
49 class InsetIndex : public InsetCollapsible {
50 public:
51         ///
52         InsetIndex(Buffer *, InsetIndexParams const &);
53         ///
54         static std::string params2string(InsetIndexParams const &);
55         ///
56         static void string2params(std::string const &, InsetIndexParams &);
57         ///
58         const InsetIndexParams& params() const { return params_; }
59         ///
60         int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
61         ///
62         InsetIndex const * asInsetIndex() const override { return this; }
63 private:
64         ///
65         bool hasSettings() const override;
66         ///
67         InsetCode lyxCode() const override { return INDEX_CODE; }
68         ///
69         docstring layoutName() const override { return from_ascii("Index"); }
70         ///
71         ColorCode labelColor() const override;
72         ///
73         void write(std::ostream & os) const override;
74         ///
75         void read(Lexer & lex) override;
76         ///
77         void docbook(XMLStream &, OutputParams const &) const override;
78         ///
79         docstring xhtml(XMLStream &, OutputParams const &) const override;
80         ///
81         void latex(otexstream &, OutputParams const &) const override;
82         ///
83         void processLatexSorting(otexstream &, OutputParams const &,
84                                  docstring const, docstring const) const;
85         ///
86         bool showInsetDialog(BufferView *) const override;
87         ///
88         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
89         ///
90         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
91         /// should paragraph indentation be omitted in any case?
92         bool neverIndent() const override { return true; }
93         ///
94         void addToToc(DocIterator const & di, bool output_active,
95                                   UpdateType utype, TocBackend & backend) const override;
96         ///
97         docstring toolTip(BufferView const & bv, int x, int y) const override;
98         ///
99         docstring const buttonLabel(BufferView const & bv) const override;
100         /// Updates needed features for this inset.
101         void validate(LaTeXFeatures & features) const override;
102         ///
103         void getSortkey(otexstream &, OutputParams const &) const;
104         ///
105         docstring getSortkeyAsText(OutputParams const &) const;
106         ///
107         void emptySubentriesWarning(docstring const & mainentry) const;
108         ///
109         void getSubentries(otexstream &, OutputParams const &, docstring const &) const;
110         ///
111         std::vector<docstring> getSubentriesAsText(OutputParams const &,
112                                                    bool const asLabel = false) const;
113         ///
114         docstring getMainSubentryAsText(OutputParams const & runparams) const;
115         ///
116         void getSeeRefs(otexstream &, OutputParams const &) const;
117         ///
118         docstring getSeeAsText(OutputParams const & runparams,
119                                bool const asLabel = false) const;
120         ///
121         std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams,
122                                                   bool const asLabel = false) const;
123         ///
124         bool hasSubentries() const;
125         ///
126         bool hasSeeRef() const;
127         ///
128         bool hasSortKey() const;
129         ///
130         bool macrosPossible(std::string const type) const;
131         ///
132         std::string contextMenuName() const override;
133         ///
134         std::string contextMenu(BufferView const &, int, int) const override;
135         ///
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; }
139         ///
140         bool insetAllowed(InsetCode code) const override;
141
142         ///
143         friend class InsetIndexParams;
144         ///
145         friend class IndexEntry;
146         ///
147         InsetIndexParams params_;
148 };
149
150
151 class InsetPrintIndex : public InsetCommand {
152 public:
153         ///
154         InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
155
156         /// \name Public functions inherited from Inset class
157         //@{
158         ///
159         InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
160         ///
161         void latex(otexstream &, OutputParams const &) const override;
162         ///
163         docstring xhtml(XMLStream &, OutputParams const &) const override;
164         ///
165         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
166         ///
167         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
168         ///
169         void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
170         ///
171         std::string contextMenuName() const override;
172         /// Updates needed features for this inset.
173         void validate(LaTeXFeatures & features) const override;
174         ///
175         bool hasSettings() const override;
176         ///
177         int rowFlags() const override { return Display; }
178         //@}
179
180         /// \name Static public methods obligated for InsetCommand derived classes
181         //@{
182         ///
183         static ParamInfo const & findInfo(std::string const &);
184         ///
185         static std::string defaultCommand() { return "printindex"; }
186         ///
187         static bool isCompatibleCommand(std::string const & s);
188         //@}
189
190 private:
191         /// \name Private functions inherited from Inset class
192         //@{
193         ///
194         Inset * clone() const override { return new InsetPrintIndex(*this); }
195         //@}
196
197         /// \name Private functions inherited from InsetCommand class
198         //@{
199         ///
200         docstring screenLabel() const override;
201         //@}
202 };
203
204
205 } // namespace lyx
206
207 #endif