]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCitation.h
af817dddb87d6db1e958d3708ce4e8026d550bab
[lyx.git] / src / insets / InsetCitation.h
1 // -*- C++ -*-
2 /**
3  * \file InsetCitation.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_CITATION_H
14 #define INSET_CITATION_H
15
16 #include "InsetCommand.h"
17
18 #include "Citation.h"
19 #include "support/strfwd.h"
20
21 namespace lyx {
22
23 /////////////////////////////////////////////////////////////////////////
24 //
25 // InsetCitation
26 //
27 /////////////////////////////////////////////////////////////////////////
28
29 /// Used to insert citations
30 class InsetCitation : public InsetCommand
31 {
32 public:
33         ///
34         InsetCitation(Buffer * buf, InsetCommandParams const &);
35         ///
36         ~InsetCitation();
37
38         ///
39         bool addKey(std::string const & key);
40
41         /// \name Public functions inherited from Inset class
42         //@{
43         ///
44         bool isLabeled() const { return true; }
45         ///
46         bool hasSettings() const { return true; }
47         ///
48         docstring toolTip(BufferView const & bv, int x, int y) const;
49         ///
50         void doDispatch(Cursor & cur, FuncRequest & cmd);
51         ///
52         InsetCode lyxCode() const { return CITE_CODE; }
53         ///
54         void latex(otexstream &, OutputParams const &) const;
55         ///
56         int plaintext(odocstream &, OutputParams const &) const;
57         ///
58         int docbook(odocstream &, OutputParams const &) const;
59         ///
60         docstring xhtml(XHTMLStream &, OutputParams const &) const;
61         ///
62         void toString(odocstream &) const;
63         ///
64         void forToc(docstring &, size_t) const;
65         ///
66         void validate(LaTeXFeatures &) const {}
67         ///
68         void updateBuffer(ParIterator const & it, UpdateType);
69         ///
70         void addToToc(DocIterator const &) const;
71         ///
72         std::string contextMenuName() const;
73         //@}
74
75         /// \name Static public methods obligated for InsetCommand derived classes
76         //@{
77         ///
78         static ParamInfo const & findInfo(std::string const &);
79         ///
80         static std::string defaultCommand() { return "cite"; }
81         ///
82         static bool isCompatibleCommand(std::string const & cmd);
83         //@}
84
85 private:
86         /// tries to make a pretty label and makes a basic one if not
87         docstring generateLabel(bool for_xhtml = false) const;
88         /// makes a pretty label
89         docstring complexLabel(bool for_xhtml = false) const;
90         /// makes a very basic label, in case we can't make a pretty one
91         docstring basicLabel(bool for_xhtml = false) const;
92
93         /// \name Private functions inherited from Inset class
94         //@{
95         ///
96         Inset * clone() const { return new InsetCitation(*this); }
97         //@}
98
99         /// \name Private functions inherited from InsetCommand class
100         //@{
101         ///
102         docstring screenLabel() const;
103         //@}
104
105         /// we'll eventually want to be able to get info on this from the
106         /// various CiteEngines
107         static ParamInfo param_info_;
108
109         ///
110         struct Cache {
111                 Cache() : recalculate(true) {};
112                 ///
113                 bool recalculate;
114                 ///
115                 docstring generated_label;
116                 ///
117                 docstring screen_label;
118         };
119         ///
120         mutable Cache cache;
121 };
122
123
124 } // namespace lyx
125
126 #endif // INSET_CITATION_H