]> git.lyx.org Git - lyx.git/blob - src/insets/insetcite.h
fix #832
[lyx.git] / src / insets / insetcite.h
1 // -*- C++ -*-
2 /**
3  * \file insetcite.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 Voss
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #ifndef INSET_CITE_H
14 #define INSET_CITE_H
15
16
17 #include "insetcommand.h"
18
19 /** Used to insert citations
20  */
21 class InsetCitation : public InsetCommand {
22 public:
23         ///
24         InsetCitation(InsetCommandParams const &, bool same_id = false);
25         ///
26         ~InsetCitation();
27         ///
28         Inset * clone(Buffer const &, bool same_id = false) const {
29                 return new InsetCitation(params(), same_id);
30         }
31         ///
32         string const getScreenLabel(Buffer const *) const;
33         ///
34         EDITABLE editable() const { return IS_EDITABLE; }
35         ///
36         Inset::Code lyxCode() const { return Inset::CITE_CODE; }
37         ///
38         int ascii(Buffer const *, std::ostream &, int linelen) const;
39         ///
40         int latex(Buffer const *, std::ostream &, bool, bool) const;
41         ///
42         dispatch_result localDispatch(FuncRequest const & cmd);
43         ///
44         void validate(LaTeXFeatures &) const;
45         /** Invoked by BufferView::Pimpl::dispatch when a new citation key
46             is inserted. Tells us that the buffer is no longer being loaded
47             and that the cache of BibTeX keys should be reloaded in the future.
48         */
49         void setLoadingBuffer(Buffer const * buffer, bool state) const;
50 private:
51         struct Cache {
52                 ///
53                 enum Style {
54                         ///
55                         BASIC,
56                         ///
57                         NATBIB_AY,
58                         ///
59                         NATBIB_NUM
60                 };
61                 ///
62                 Cache() : style(BASIC) {}
63                 ///
64                 Style style;
65                 ///
66                 InsetCommandParams params;
67                 ///
68                 string generated_label;
69                 ///
70                 string screen_label;
71         };
72
73         /// This function does the donkey work of creating the pretty label
74         string const generateLabel(Buffer const *) const;
75         ///
76         Cache::Style getStyle(Buffer const * buffer) const;
77
78         ///
79         mutable Cache cache;
80 };
81
82 #endif // INSET_CITE_H