]> git.lyx.org Git - features.git/blob - src/insets/InsetIndex.h
InsetIndex: hide printTree behind a LYX_INSET_INDEX_DEBUG flag
[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 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 private:
62         ///
63         bool hasSettings() const override;
64         ///
65         InsetCode lyxCode() const override { return INDEX_CODE; }
66         ///
67         docstring layoutName() const override { return from_ascii("Index"); }
68         ///
69         ColorCode labelColor() const override;
70         ///
71         void write(std::ostream & os) const override;
72         ///
73         void read(Lexer & lex) override;
74         ///
75         void docbook(XMLStream &, OutputParams const &) const override;
76         ///
77         docstring xhtml(XMLStream &, OutputParams const &) const override;
78         ///
79         void latex(otexstream &, OutputParams const &) const override;
80         ///
81         void processLatexSorting(otexstream &, OutputParams const &,
82                                  docstring const, docstring const) const;
83         ///
84         bool showInsetDialog(BufferView *) const override;
85         ///
86         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
87         ///
88         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
89         /// should paragraph indentation be omitted in any case?
90         bool neverIndent() const override { return true; }
91         ///
92         void addToToc(DocIterator const & di, bool output_active,
93                                   UpdateType utype, TocBackend & backend) const override;
94         ///
95         docstring toolTip(BufferView const & bv, int x, int y) const override;
96         ///
97         docstring const buttonLabel(BufferView const & bv) const override;
98         /// Updates needed features for this inset.
99         void validate(LaTeXFeatures & features) const override;
100         ///
101         void getSortkey(otexstream &, OutputParams const &) const;
102         ///
103         docstring getSortkeyAsText(OutputParams const &) const;
104         ///
105         void getSubentries(otexstream &, OutputParams const &) const;
106         ///
107         std::vector<docstring> getSubentriesAsText(OutputParams const &,
108                                                    bool const asLabel = false) const;
109         ///
110         docstring getMainSubentryAsText(OutputParams const & runparams) const;
111         ///
112         void getSeeRefs(otexstream &, OutputParams const &) const;
113         ///
114         docstring getSeeAsText(OutputParams const & runparams) const;
115         ///
116         std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams) const;
117         ///
118         bool hasSubentries() const;
119         ///
120         bool hasSeeRef() const;
121         ///
122         bool hasSortKey() const;
123         ///
124         bool macrosPossible(std::string const type) const;
125         ///
126         std::string contextMenuName() const override;
127         ///
128         std::string contextMenu(BufferView const &, int, int) const override;
129         ///
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; }
133         ///
134         bool insetAllowed(InsetCode code) const override;
135
136         ///
137         friend class InsetIndexParams;
138         ///
139         friend class IndexEntry;
140         ///
141         InsetIndexParams params_;
142 };
143
144
145 class InsetPrintIndex : public InsetCommand {
146 public:
147         ///
148         InsetPrintIndex(Buffer * buf, InsetCommandParams const &);
149
150         /// \name Public functions inherited from Inset class
151         //@{
152         ///
153         InsetCode lyxCode() const override { return INDEX_PRINT_CODE; }
154         ///
155         void latex(otexstream &, OutputParams const &) const override;
156         ///
157         docstring xhtml(XMLStream &, OutputParams const &) const override;
158         ///
159         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
160         ///
161         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
162         ///
163         void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
164         ///
165         std::string contextMenuName() const override;
166         /// Updates needed features for this inset.
167         void validate(LaTeXFeatures & features) const override;
168         ///
169         bool hasSettings() const override;
170         ///
171         int rowFlags() const override { return Display; }
172         //@}
173
174         /// \name Static public methods obligated for InsetCommand derived classes
175         //@{
176         ///
177         static ParamInfo const & findInfo(std::string const &);
178         ///
179         static std::string defaultCommand() { return "printindex"; }
180         ///
181         static bool isCompatibleCommand(std::string const & s);
182         //@}
183
184 private:
185         /// \name Private functions inherited from Inset class
186         //@{
187         ///
188         Inset * clone() const override { return new InsetPrintIndex(*this); }
189         //@}
190
191         /// \name Private functions inherited from InsetCommand class
192         //@{
193         ///
194         docstring screenLabel() const override;
195         //@}
196 };
197
198
199 } // namespace lyx
200
201 #endif