]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCitation.h
Merge branch 'master' into biblatex2
[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 namespace lyx {
19
20 /////////////////////////////////////////////////////////////////////////
21 //
22 // InsetCitation
23 //
24 /////////////////////////////////////////////////////////////////////////
25
26 /// Used to insert citations
27 class InsetCitation : public InsetCommand
28 {
29 public:
30         ///
31         InsetCitation(Buffer * buf, InsetCommandParams const &);
32         ///
33         ~InsetCitation();
34
35         ///
36         bool addKey(std::string const & key);
37
38         /// \name Public functions inherited from Inset class
39         //@{
40         ///
41         bool isLabeled() const { return true; }
42         ///
43         bool hasSettings() const { return true; }
44         ///
45         docstring toolTip(BufferView const & bv, int x, int y) const;
46         ///
47         void doDispatch(Cursor & cur, FuncRequest & cmd);
48         ///
49         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
50         ///
51         InsetCode lyxCode() const { return CITE_CODE; }
52         ///
53         void latex(otexstream &, OutputParams const &) const;
54         ///
55         int plaintext(odocstringstream & ods, OutputParams const & op,
56                       size_t max_length = INT_MAX) 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 forOutliner(docstring &, size_t const, bool const) const;
65         ///
66         void validate(LaTeXFeatures &) const {}
67         ///
68         void updateBuffer(ParIterator const & it, UpdateType);
69         ///
70         void addToToc(DocIterator const & di, bool output_active,
71                                   UpdateType utype) const;
72         ///
73         std::string contextMenuName() const;
74         //@}
75
76         /// \name Static public methods obligated for InsetCommand derived classes
77         //@{
78         ///
79         static ParamInfo const & findInfo(std::string const &);
80         ///
81         static std::string defaultCommand() { return "cite"; }
82         ///
83         static bool isCompatibleCommand(std::string const &);
84         //@}
85
86 private:
87         /// tries to make a pretty label and makes a basic one if not
88         docstring generateLabel(bool for_xhtml = false) const;
89         /// makes a pretty label
90         docstring complexLabel(bool for_xhtml = false) const;
91         /// makes a very basic label, in case we can't make a pretty one
92         docstring basicLabel(bool for_xhtml = false) const;
93
94         /// \name Private functions inherited from Inset class
95         //@{
96         ///
97         Inset * clone() const { return new InsetCitation(*this); }
98         //@}
99
100         /// \name Private functions inherited from InsetCommand class
101         //@{
102         ///
103         docstring screenLabel() const;
104         //@}
105
106         /// we'll eventually want to be able to get info on this from the
107         /// various CiteEngines
108         static ParamInfo param_info_;
109
110         ///
111         struct Cache {
112                 Cache() : recalculate(true) {}
113                 ///
114                 bool recalculate;
115                 ///
116                 docstring generated_label;
117                 ///
118                 docstring screen_label;
119         };
120         ///
121         mutable Cache cache;
122 };
123
124
125 } // namespace lyx
126
127 #endif // INSET_CITATION_H