3 * \file InsetCitation.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSET_CITATION_H
14 #define INSET_CITATION_H
16 #include "InsetCommand.h"
23 /////////////////////////////////////////////////////////////////////////
27 /////////////////////////////////////////////////////////////////////////
29 /// Used to insert citations
30 class InsetCitation : public InsetCommand
34 InsetCitation(Buffer * buf, InsetCommandParams const &);
39 bool addKey(std::string const & key);
41 /// \name Public functions inherited from Inset class
44 bool isLabeled() const override { return true; }
46 bool hasSettings() const override { return true; }
48 docstring toolTip(BufferView const & bv, int x, int y) const override;
50 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
52 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override;
54 InsetCode lyxCode() const override { return CITE_CODE; }
56 void latex(otexstream &, OutputParams const &) const override;
58 int plaintext(odocstringstream & ods, OutputParams const & op,
59 size_t max_length = INT_MAX) const override;
61 void docbook(XMLStream &, OutputParams const &) const override;
63 docstring xhtml(XMLStream &, OutputParams const &) const override;
65 bool findUsesToString() const override { return true; }
67 void toString(odocstream &) const override;
69 void forOutliner(docstring &, size_t const, bool const) const override;
71 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
73 void addToToc(DocIterator const & di, bool output_active,
74 UpdateType utype, TocBackend & backend) const override;
76 std::string contextMenuName() const override;
78 bool forceLTR(OutputParams const &) const override;
81 /// \name Static public methods obligated for InsetCommand derived classes
84 static ParamInfo const & findInfo(std::string const &);
86 static std::string defaultCommand() { return "cite"; }
88 static bool isCompatibleCommand(std::string const &);
91 typedef std::vector<std::pair<docstring, docstring>> QualifiedList;
93 void redoLabel() { cache.recalculate = true; }
95 CitationStyle getCitationStyle(BufferParams const & bp, std::string const & input,
96 std::vector<CitationStyle> const & valid_styles) const;
98 QualifiedList getQualifiedLists(docstring const & p) const;
100 static bool last_literal;
101 /// Check whether citation contains necessary url/file entries
102 /// or external search script is available
103 bool openCitationPossible() const;
104 /// search and open citation source
107 std::pair<int, int> isWords() const override;
110 /// tries to make a pretty label and makes a basic one if not
111 docstring generateLabel(bool for_xhtml = false) const;
112 /// makes a pretty label
113 docstring complexLabel(bool for_xhtml = false) const;
114 /// makes a very basic label, in case we can't make a pretty one
115 docstring basicLabel(bool for_xhtml = false) const;
119 /// \name Private functions inherited from Inset class
122 Inset * clone() const override { return new InsetCitation(*this); }
125 /// \name Private functions inherited from InsetCommand class
128 docstring screenLabel() const override;
133 Cache() : recalculate(true) {}
137 docstring generated_label;
139 docstring screen_label;
148 #endif // INSET_CITATION_H