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