]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndex.h
97a82babf575fe8547ea1b657b8fd38860db32be
[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 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         void getSubentries(otexstream &, OutputParams const &) const;
98         ///
99         void getSeeRefs(otexstream &, OutputParams const &) const;
100         ///
101         bool hasSeeRef() const;
102         ///
103         bool hasSortKey() const;
104         ///
105         bool macrosPossible(std::string const type) const;
106         ///
107         std::string contextMenuName() const override;
108         ///
109         std::string contextMenu(BufferView const &, int, int) const override;
110         ///
111         Inset * clone() const override { return new InsetIndex(*this); }
112         /// Is the content of this inset part of the immediate text sequence?
113         bool isPartOfTextSequence() const override { return false; }
114         ///
115         bool insetAllowed(InsetCode code) const override;
116
117         ///
118         friend class InsetIndexParams;
119         ///
120         InsetIndexParams params_;
121 };
122
123
124 class InsetPrintIndex : public InsetCommand {
125 public:
126         ///
127         InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
128
129         /// \name Public functions inherited from Inset class
130         //@{
131         ///
132         InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
133         ///
134         void latex(otexstream &, OutputParams const &) const override;
135         ///
136         docstring xhtml(XMLStream &, OutputParams const &) const override;
137         ///
138         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
139         ///
140         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
141         ///
142         void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
143         ///
144         std::string contextMenuName() const override;
145         /// Updates needed features for this inset.
146         void validate(LaTeXFeatures & features) const override;
147         ///
148         bool hasSettings() const override;
149         ///
150         int rowFlags() const override { return Display; }
151         //@}
152
153         /// \name Static public methods obligated for InsetCommand derived classes
154         //@{
155         ///
156         static ParamInfo const & findInfo(std::string const &);
157         ///
158         static std::string defaultCommand() { return "printindex"; }
159         ///
160         static bool isCompatibleCommand(std::string const & s);
161         //@}
162
163 private:
164         /// \name Private functions inherited from Inset class
165         //@{
166         ///
167         Inset * clone() const override { return new InsetPrintIndex(*this); }
168         //@}
169
170         /// \name Private functions inherited from InsetCommand class
171         //@{
172         ///
173         docstring screenLabel() const override;
174         //@}
175 };
176
177
178 } // namespace lyx
179
180 #endif