]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCitation.h
9140dc704099961ea267a1110dedaf516c2e15b1
[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(InsetCommandParams const &);
36         ///
37         bool isLabeled() const { return true; }
38         ///
39         docstring screenLabel() const;
40         ///
41         EDITABLE editable() const { return IS_EDITABLE; }
42         ///
43         InsetCode lyxCode() const { return CITE_CODE; }
44         ///
45         int latex(odocstream &, OutputParams const &) const;
46         ///
47         int plaintext(odocstream &, OutputParams const &) const;
48         ///
49         int docbook(odocstream &, OutputParams const &) const;
50         /// the string that is passed to the TOC
51         void textString(odocstream &) const;
52         ///
53         void validate(LaTeXFeatures &) const;
54         ///
55         void updateLabels(ParIterator const & it);
56         ///
57         void addToToc(ParConstIterator const &) const;
58
59         ///
60         static ParamInfo const & findInfo(std::string const &);
61         // FIXME This is the locus of the design problem we have.
62         // It really ought to do what default_cite_command() does,
63         // but to do that it needs to know what CiteEngine we are
64         // using.
65         static std::string defaultCommand() { return "cite"; }
66         ///
67         static bool isCompatibleCommand(std::string const & cmd);
68 private:
69         ///
70         Inset * clone() const { return new InsetCitation(*this); }
71         /// we'll eventually want to be able to get info on this from the 
72         /// various CiteEngines
73         static ParamInfo param_info_;
74         /// This function does the donkey work of creating the pretty label
75         docstring generateLabel() const;
76
77         ///
78         class Cache {
79         public:
80                 ///
81                 Cache() : engine(ENGINE_BASIC), params(CITE_CODE) {}
82                 ///
83                 CiteEngine engine;
84                 ///
85                 InsetCommandParams params;
86                 ///
87                 docstring generated_label;
88                 ///
89                 docstring screen_label;
90         };
91         ///
92         mutable Cache cache;
93 };
94
95 } // namespace lyx
96
97 #endif // INSET_CITATION_H