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"
22 /////////////////////////////////////////////////////////////////////////
26 /////////////////////////////////////////////////////////////////////////
28 /// Used to insert citations
29 class InsetCitation : public InsetCommand
33 InsetCitation(Buffer * buf, InsetCommandParams const &);
38 bool addKey(std::string const & key);
40 /// \name Public functions inherited from Inset class
43 bool isLabeled() const override { return true; }
45 bool hasSettings() const override { return true; }
47 docstring toolTip(BufferView const & bv, int x, int y) const override;
49 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
51 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override;
53 InsetCode lyxCode() const override { return CITE_CODE; }
55 void latex(otexstream &, OutputParams const &) const override;
57 int plaintext(odocstringstream & ods, OutputParams const & op,
58 size_t max_length = INT_MAX) const override;
60 void docbook(XMLStream &, OutputParams const &) const override;
62 docstring xhtml(XMLStream &, OutputParams const &) const override;
64 void toString(odocstream &) const override;
66 void forOutliner(docstring &, size_t const, bool const) const override;
68 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
70 void addToToc(DocIterator const & di, bool output_active,
71 UpdateType utype, TocBackend & backend) const override;
73 std::string contextMenuName() const override;
75 bool forceLTR(OutputParams const &) const override;
78 /// \name Static public methods obligated for InsetCommand derived classes
81 static ParamInfo const & findInfo(std::string const &);
83 static std::string defaultCommand() { return "cite"; }
85 static bool isCompatibleCommand(std::string const &);
88 typedef std::vector<std::pair<docstring, docstring>> QualifiedList;
90 void redoLabel() { cache.recalculate = true; }
92 CitationStyle getCitationStyle(BufferParams const & bp, std::string const & input,
93 std::vector<CitationStyle> const & valid_styles) const;
95 QualifiedList getQualifiedLists(docstring const & p) const;
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
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;
112 /// \name Private functions inherited from Inset class
115 Inset * clone() const override { return new InsetCitation(*this); }
118 /// \name Private functions inherited from InsetCommand class
121 docstring screenLabel() const override;
126 Cache() : recalculate(true) {}
130 docstring generated_label;
132 docstring screen_label;
141 #endif // INSET_CITATION_H