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