]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndexMacro.h
Merge branch 'master' into features/indexmacros
[lyx.git] / src / insets / InsetIndexMacro.h
1 // -*- C++ -*-
2 /**
3  * \file InsetIndexMacro.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_INSETMACRO_H
13 #define INSET_INSETMACRO_H
14
15
16 #include "Inset.h"
17 #include "InsetCollapsible.h"
18
19
20 namespace lyx {
21
22 class LaTeXFeatures;
23
24 class InsetIndexMacroParams
25 {
26 public:
27         enum Type {
28                 See,
29                 Seealso,
30                 Subindex,
31                 Sortkey
32         };
33         ///
34         InsetIndexMacroParams();
35         ///
36         void write(std::ostream & os) const;
37         ///
38         void read(Lexer & lex);
39         ///
40         Type type;
41 };
42
43 /////////////////////////////////////////////////////////////////////////
44 //
45 // InsetIndexMacro
46 //
47 /////////////////////////////////////////////////////////////////////////
48
49 /// Used to insert index references
50 class InsetIndexMacro : public InsetCollapsible
51 {
52 public:
53         ///
54         InsetIndexMacro(Buffer *, std::string const &);
55         ///
56         ~InsetIndexMacro();
57         ///
58         static std::string params2string(InsetIndexMacroParams const &);
59         ///
60         static void string2params(std::string const &, InsetIndexMacroParams &);
61         ///
62         InsetIndexMacroParams const & params() const { return params_; }
63         ///
64         void getLatex(otexstream &, OutputParams const &) const;
65         ///
66         int getPlaintext(odocstringstream &, OutputParams const &, size_t) const;
67         ///
68         void getDocbook(XMLStream &, OutputParams const &) const;
69 private:
70         ///
71         InsetCode lyxCode() const override;
72         ///
73         docstring layoutName() const override;
74         ///
75         void write(std::ostream &) const override;
76         ///
77         void read(Lexer & lex) override;
78         ///
79         bool neverIndent() const override { return true; }
80         /// We do not output anything directly to the stream
81         void latex(otexstream &, OutputParams const &) const override {};
82         /// We do not output anything directly to the stream
83         int plaintext(odocstringstream &, OutputParams const &, size_t) const override { return 0; };
84         /// We do not output anything directly to the stream
85         void docbook(XMLStream &, OutputParams const &) const override {};
86         /// We do not output anything directly to the stream
87         docstring xhtml(XMLStream &, OutputParams const &) const override { return docstring(); };
88         ///
89         docstring getXhtml(XMLStream &, OutputParams const &) const;
90         ///
91         bool allowSpellCheck() const override { return false; }
92         ///
93         bool insetAllowed(InsetCode code) const override;
94         ///
95         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
96         ///
97         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
98         ///
99         docstring toolTip(BufferView const & bv, int x, int y) const override;
100         ///
101         void processLatexSorting(otexstream &, OutputParams const &,
102                             docstring const, docstring const) const;
103         ///
104         bool hasSortKey() const;
105         ///
106         void getSortkey(otexstream &, OutputParams const &) const;
107         ///
108         std::string contextMenuName() const override;
109         ///
110         std::string contextMenu(BufferView const &, int, int) const override;
111         ///
112         Inset * clone() const override { return new InsetIndexMacro(*this); }
113         /// used by the constructors
114         void init();
115         ///
116         friend class InsetIndexMacroParams;
117
118         ///
119         InsetIndexMacroParams params_;
120 };
121
122
123 } // namespace lyx
124
125 #endif