]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCitation.h
Fix bug #6315: counters in insets that don't produce output have ghost values.
[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
20 namespace lyx {
21
22 /////////////////////////////////////////////////////////////////////////
23 //
24 // InsetCitation
25 //
26 /////////////////////////////////////////////////////////////////////////
27
28 /// Used to insert citations
29 class InsetCitation : public InsetCommand
30 {
31 public:
32         ///
33         InsetCitation(Buffer * buf, InsetCommandParams const &);
34
35         /// \name Public functions inherited from Inset class
36         //@{
37         ///
38         bool isLabeled() const { return true; }
39         ///
40         bool hasSettings() const { return true; }
41         ///
42         docstring toolTip(BufferView const & bv, int x, int y) const;
43         ///
44         InsetCode lyxCode() const { return CITE_CODE; }
45         ///
46         int latex(odocstream &, OutputParams const &) const;
47         ///
48         int plaintext(odocstream &, OutputParams const &) const;
49         ///
50         int docbook(odocstream &, OutputParams const &) const;
51         ///
52         docstring xhtml(XHTMLStream &, OutputParams const &) const;
53         ///
54         void tocString(odocstream &) const;
55         ///
56         void validate(LaTeXFeatures &) const;
57         ///
58         void updateBuffer(ParIterator const & it, UpdateType);
59         ///
60         void addToToc(DocIterator const &);
61         ///
62         docstring contextMenu(BufferView const & bv, int x, int y) const;
63         //@}
64
65         /// \name Static public methods obligated for InsetCommand derived classes
66         //@{
67         ///
68         static ParamInfo const & findInfo(std::string const &);
69         // FIXME This is the locus of the design problem we have.
70         // It really ought to do what default_cite_command() does,
71         // but to do that it needs to know what CiteEngine we are
72         // using.
73         static std::string defaultCommand() { return "cite"; }
74         ///
75         static bool isCompatibleCommand(std::string const & cmd);
76         //@}
77
78 private:
79         /// tries to make a pretty label and makes a basic one if not
80         docstring generateLabel(bool for_xhtml = false) const;
81         /// makes a pretty label
82         docstring complexLabel(bool for_xhtml = false) const;
83         /// makes a very basic label, in case we can't make a pretty one
84         docstring basicLabel(bool for_xhtml = false) const;
85
86         /// \name Private functions inherited from Inset class
87         //@{
88         ///
89         Inset * clone() const { return new InsetCitation(*this); }
90         //@}
91
92         /// \name Private functions inherited from InsetCommand class
93         //@{
94         ///
95         docstring screenLabel() const;
96         //@}
97
98         /// we'll eventually want to be able to get info on this from the 
99         /// various CiteEngines
100         static ParamInfo param_info_;
101
102         ///
103         class Cache {
104         public:
105                 ///
106                 Cache() : engine(ENGINE_BASIC), params(CITE_CODE) {}
107                 ///
108                 CiteEngine engine;
109                 ///
110                 InsetCommandParams params;
111                 ///
112                 docstring generated_label;
113                 ///
114                 docstring screen_label;
115         };
116         ///
117         mutable Cache cache;
118 };
119
120
121 } // namespace lyx
122
123 #endif // INSET_CITATION_H