]> git.lyx.org Git - features.git/blob - src/insets/InsetIndex.h
DocBook, InsetFloat: avoid a potential nullptr dereference when detecting the type...
[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         ///
25         explicit InsetIndexParams(docstring const & b = docstring())
26                 : index(b) {}
27         ///
28         void write(std::ostream & os) const;
29         ///
30         void read(Lexer & lex);
31         ///
32         docstring index;
33 };
34
35
36 /** Used to insert index labels
37   */
38 class InsetIndex : public InsetCollapsible {
39 public:
40         ///
41         InsetIndex(Buffer *, InsetIndexParams const &);
42         ///
43         static std::string params2string(InsetIndexParams const &);
44         ///
45         static void string2params(std::string const &, InsetIndexParams &);
46 private:
47         ///
48         bool hasSettings() const override;
49         ///
50         InsetCode lyxCode() const override { return INDEX_CODE; }
51         ///
52         docstring layoutName() const override { return from_ascii("Index"); }
53         ///
54         ColorCode labelColor() const override;
55         ///
56         void write(std::ostream & os) const override;
57         ///
58         void read(Lexer & lex) override;
59         ///
60         void docbook(XMLStream &, OutputParams const &) const override;
61         ///
62         docstring xhtml(XMLStream &, OutputParams const &) const override;
63         ///
64         void latex(otexstream &, OutputParams const &) const override;
65         ///
66         bool showInsetDialog(BufferView *) const override;
67         ///
68         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
69         ///
70         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
71         /// should paragraph indentation be omitted in any case?
72         bool neverIndent() const override { return true; }
73         ///
74         void addToToc(DocIterator const & di, bool output_active,
75                                   UpdateType utype, TocBackend & backend) const override;
76         ///
77         docstring toolTip(BufferView const & bv, int x, int y) const override;
78         ///
79         docstring const buttonLabel(BufferView const & bv) const override;
80         /// Updates needed features for this inset.
81         void validate(LaTeXFeatures & features) const override;
82         ///
83         std::string contextMenuName() const override;
84         ///
85         Inset * clone() const override { return new InsetIndex(*this); }
86         /// Is the content of this inset part of the immediate text sequence?
87         bool isPartOfTextSequence() const override { return false; }
88
89         ///
90         friend class InsetIndexParams;
91         ///
92         InsetIndexParams params_;
93 };
94
95
96 class InsetPrintIndex : public InsetCommand {
97 public:
98         ///
99         InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
100
101         /// \name Public functions inherited from Inset class
102         //@{
103         ///
104         InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
105         ///
106         void latex(otexstream &, OutputParams const &) const override;
107         ///
108         docstring xhtml(XMLStream &, OutputParams const &) const override;
109         ///
110         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
111         ///
112         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
113         ///
114         void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
115         ///
116         std::string contextMenuName() const override;
117         /// Updates needed features for this inset.
118         void validate(LaTeXFeatures & features) const override;
119         ///
120         bool hasSettings() const override;
121         ///
122         int rowFlags() const override { return Display; }
123         //@}
124
125         /// \name Static public methods obligated for InsetCommand derived classes
126         //@{
127         ///
128         static ParamInfo const & findInfo(std::string const &);
129         ///
130         static std::string defaultCommand() { return "printindex"; }
131         ///
132         static bool isCompatibleCommand(std::string const & s);
133         //@}
134
135 private:
136         /// \name Private functions inherited from Inset class
137         //@{
138         ///
139         Inset * clone() const override { return new InsetPrintIndex(*this); }
140         //@}
141
142         /// \name Private functions inherited from InsetCommand class
143         //@{
144         ///
145         docstring screenLabel() const override;
146         //@}
147 };
148
149
150 } // namespace lyx
151
152 #endif