]> git.lyx.org Git - features.git/blob - src/insets/InsetIndex.h
Merge branch 'master' into features/indexmacros
[features.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 InsetIndexParams {
23 public:
24         enum PageRange {
25                 None,
26                 Start,
27                 End
28         };
29         ///
30         explicit InsetIndexParams(docstring const & b = docstring())
31                 : index(b), range(None), pagefmt("default") {}
32         ///
33         void write(std::ostream & os) const;
34         ///
35         void read(Lexer & lex);
36         ///
37         docstring index;
38         ///
39         PageRange range;
40         ///
41         std::string pagefmt;
42 };
43
44
45 /** Used to insert index labels
46   */
47 class InsetIndex : public InsetCollapsible {
48 public:
49         ///
50         InsetIndex(Buffer *, InsetIndexParams const &);
51         ///
52         static std::string params2string(InsetIndexParams const &);
53         ///
54         static void string2params(std::string const &, InsetIndexParams &);
55 private:
56         ///
57         bool hasSettings() const override;
58         ///
59         InsetCode lyxCode() const override { return INDEX_CODE; }
60         ///
61         docstring layoutName() const override { return from_ascii("Index"); }
62         ///
63         ColorCode labelColor() const override;
64         ///
65         void write(std::ostream & os) const override;
66         ///
67         void read(Lexer & lex) override;
68         ///
69         void docbook(XMLStream &, OutputParams const &) const override;
70         ///
71         docstring xhtml(XMLStream &, OutputParams const &) const override;
72         ///
73         void latex(otexstream &, OutputParams const &) const override;
74         ///
75         void processLatexSorting(otexstream &, OutputParams const &,
76                                  docstring const, docstring const) const;
77         ///
78         bool showInsetDialog(BufferView *) const override;
79         ///
80         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
81         ///
82         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
83         /// should paragraph indentation be omitted in any case?
84         bool neverIndent() const override { return true; }
85         ///
86         void addToToc(DocIterator const & di, bool output_active,
87                                   UpdateType utype, TocBackend & backend) const override;
88         ///
89         docstring toolTip(BufferView const & bv, int x, int y) const override;
90         ///
91         docstring const buttonLabel(BufferView const & bv) const override;
92         /// Updates needed features for this inset.
93         void validate(LaTeXFeatures & features) const override;
94         ///
95         void getSortkey(otexstream &, OutputParams const &) const;
96         ///
97         docstring getSortkeyAsText(OutputParams const &) const;
98         ///
99         void getSubentries(otexstream &, OutputParams const &) const;
100         ///
101         std::vector<docstring> getSubentriesAsText(OutputParams const &) const;
102         ///
103         void getSeeRefs(otexstream &, OutputParams const &) const;
104         ///
105         docstring getSeeAsText(OutputParams const & runparams) const;
106         ///
107         std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams) const;
108         ///
109         bool hasSeeRef() const;
110         ///
111         bool hasSortKey() const;
112         ///
113         bool macrosPossible(std::string const type) const;
114         ///
115         std::string contextMenuName() const override;
116         ///
117         std::string contextMenu(BufferView const &, int, int) const override;
118         ///
119         Inset * clone() const override { return new InsetIndex(*this); }
120         /// Is the content of this inset part of the immediate text sequence?
121         bool isPartOfTextSequence() const override { return false; }
122         ///
123         bool insetAllowed(InsetCode code) const override;
124
125         ///
126         friend class InsetIndexParams;
127         ///
128         InsetIndexParams params_;
129 };
130
131
132 class InsetPrintIndex : public InsetCommand {
133 public:
134         ///
135         InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
136
137         /// \name Public functions inherited from Inset class
138         //@{
139         ///
140         InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
141         ///
142         void latex(otexstream &, OutputParams const &) const override;
143         ///
144         docstring xhtml(XMLStream &, OutputParams const &) const override;
145         ///
146         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
147         ///
148         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
149         ///
150         void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
151         ///
152         std::string contextMenuName() const override;
153         /// Updates needed features for this inset.
154         void validate(LaTeXFeatures & features) const override;
155         ///
156         bool hasSettings() const override;
157         ///
158         int rowFlags() const override { return Display; }
159         //@}
160
161         /// \name Static public methods obligated for InsetCommand derived classes
162         //@{
163         ///
164         static ParamInfo const & findInfo(std::string const &);
165         ///
166         static std::string defaultCommand() { return "printindex"; }
167         ///
168         static bool isCompatibleCommand(std::string const & s);
169         //@}
170
171 private:
172         /// \name Private functions inherited from Inset class
173         //@{
174         ///
175         Inset * clone() const override { return new InsetPrintIndex(*this); }
176         //@}
177
178         /// \name Private functions inherited from InsetCommand class
179         //@{
180         ///
181         docstring screenLabel() const override;
182         //@}
183 };
184
185
186 } // namespace lyx
187
188 #endif