]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCitation.h
InsetInfo: enable inset dissolve
[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 "Citation.h"
18
19 namespace lyx {
20
21 /////////////////////////////////////////////////////////////////////////
22 //
23 // InsetCitation
24 //
25 /////////////////////////////////////////////////////////////////////////
26
27 /// Used to insert citations
28 class InsetCitation : public InsetCommand
29 {
30 public:
31         ///
32         InsetCitation(Buffer * buf, InsetCommandParams const &);
33         ///
34         ~InsetCitation();
35
36         ///
37         bool addKey(std::string const & key);
38
39         /// \name Public functions inherited from Inset class
40         //@{
41         ///
42         bool isLabeled() const { return true; }
43         ///
44         bool hasSettings() const { return true; }
45         ///
46         docstring toolTip(BufferView const & bv, int x, int y) const;
47         ///
48         void doDispatch(Cursor & cur, FuncRequest & cmd);
49         ///
50         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
51         ///
52         InsetCode lyxCode() const { return CITE_CODE; }
53         ///
54         void latex(otexstream &, OutputParams const &) const;
55         ///
56         int plaintext(odocstringstream & ods, OutputParams const & op,
57                       size_t max_length = INT_MAX) const;
58         ///
59         int docbook(odocstream &, OutputParams const &) const;
60         ///
61         docstring xhtml(XHTMLStream &, OutputParams const &) const;
62         ///
63         void toString(odocstream &) const;
64         ///
65         void forOutliner(docstring &, size_t const, bool const) const;
66         ///
67         void updateBuffer(ParIterator const & it, UpdateType);
68         ///
69         void addToToc(DocIterator const & di, bool output_active,
70                                   UpdateType utype, TocBackend & backend) const;
71         ///
72         std::string contextMenuName() const;
73         //@}
74
75         /// \name Static public methods obligated for InsetCommand derived classes
76         //@{
77         ///
78         static ParamInfo const & findInfo(std::string const &);
79         ///
80         static std::string defaultCommand() { return "cite"; }
81         ///
82         static bool isCompatibleCommand(std::string const &);
83         //@}
84         ///
85         void redoLabel() { cache.recalculate = true; }
86         ///
87         CitationStyle getCitationStyle(BufferParams const & bp, std::string const & input,
88                                        std::vector<CitationStyle> const & valid_styles) const;
89         ///
90         std::map<docstring, docstring> getQualifiedLists(docstring const p) const;
91         ///
92         static bool last_literal;
93
94 private:
95         /// tries to make a pretty label and makes a basic one if not
96         docstring generateLabel(bool for_xhtml = false) const;
97         /// makes a pretty label
98         docstring complexLabel(bool for_xhtml = false) const;
99         /// makes a very basic label, in case we can't make a pretty one
100         docstring basicLabel(bool for_xhtml = false) const;
101
102         /// \name Private functions inherited from Inset class
103         //@{
104         ///
105         Inset * clone() const { return new InsetCitation(*this); }
106         //@}
107
108         /// \name Private functions inherited from InsetCommand class
109         //@{
110         ///
111         docstring screenLabel() const;
112         //@}
113
114         ///
115         struct Cache {
116                 Cache() : recalculate(true) {}
117                 ///
118                 bool recalculate;
119                 ///
120                 docstring generated_label;
121                 ///
122                 docstring screen_label;
123         };
124         ///
125         mutable Cache cache;
126 };
127
128
129 } // namespace lyx
130
131 #endif // INSET_CITATION_H