]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCitation.h
s/updateLabels/updateBuffer/g, per a suggestion of Abdel's.
[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         explicit InsetCitation(Buffer * buf, InsetCommandParams const &);
36         ///
37         bool isLabeled() const { return true; }
38         ///
39         docstring screenLabel() const;
40         ///
41         bool hasSettings() const { return true; }
42         ///
43         docstring toolTip(BufferView const & bv, int x, int y) const;
44         ///
45         InsetCode lyxCode() const { return CITE_CODE; }
46         ///
47         int latex(odocstream &, OutputParams const &) const;
48         ///
49         int plaintext(odocstream &, OutputParams const &) const;
50         ///
51         int docbook(odocstream &, OutputParams const &) const;
52         ///
53         docstring xhtml(XHTMLStream &, OutputParams const &) const;
54         /// the string that is passed to the TOC
55         void tocString(odocstream &) const;
56         ///
57         void validate(LaTeXFeatures &) const;
58         ///
59         void updateBuffer(ParIterator const & it, UpdateType);
60         ///
61         void addToToc(DocIterator const &);
62
63         ///
64         static ParamInfo const & findInfo(std::string const &);
65         // FIXME This is the locus of the design problem we have.
66         // It really ought to do what default_cite_command() does,
67         // but to do that it needs to know what CiteEngine we are
68         // using.
69         static std::string defaultCommand() { return "cite"; }
70         ///
71         static bool isCompatibleCommand(std::string const & cmd);
72         ///
73         virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
74 private:
75         ///
76         Inset * clone() const { return new InsetCitation(*this); }
77         /// tries to make a pretty label and makes a basic one if not
78         docstring generateLabel(bool for_xhtml = false) const;
79         /// makes a pretty label
80         docstring complexLabel(bool for_xhtml = false) const;
81         /// makes a very basic label, in case we can't make a pretty one
82         docstring basicLabel(bool for_xhtml = false) const;
83         /// we'll eventually want to be able to get info on this from the 
84         /// various CiteEngines
85         static ParamInfo param_info_;
86
87         ///
88         class Cache {
89         public:
90                 ///
91                 Cache() : engine(ENGINE_BASIC), params(CITE_CODE) {}
92                 ///
93                 CiteEngine engine;
94                 ///
95                 InsetCommandParams params;
96                 ///
97                 docstring generated_label;
98                 ///
99                 docstring screen_label;
100         };
101         ///
102         mutable Cache cache;
103 };
104
105 } // namespace lyx
106
107 #endif // INSET_CITATION_H