4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "InsetCommand.h"
20 /// The reference inset
21 class InsetRef : public InsetCommand {
25 std::string latex_name;
29 std::string short_gui_name;
31 static const type_info types[];
34 InsetRef(Buffer * buffer, InsetCommandParams const &);
37 void changeTarget(docstring const & new_label);
39 /// \name Public functions inherited from Inset class
42 docstring layoutName() const override;
44 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
46 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const override;
48 bool isLabeled() const override { return true; }
50 docstring toolTip(BufferView const &, int, int) const override
53 docstring getTOCString() const;
55 bool hasSettings() const override { return true; }
57 InsetCode lyxCode() const override { return REF_CODE; }
59 void latex(otexstream &, OutputParams const &) const override;
61 int plaintext(odocstringstream & ods, OutputParams const & op,
62 size_t max_length = INT_MAX) const override;
64 void docbook(XMLStream &, OutputParams const &) const override;
66 docstring xhtml(XMLStream &, OutputParams const &) const override;
68 bool findUsesToString() const override { return true; }
70 void toString(odocstream &) const override;
72 void forOutliner(docstring &, size_t const, bool const) const override;
74 void validate(LaTeXFeatures & features) const override;
76 void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false) override;
78 void addToToc(DocIterator const & di, bool output_active,
79 UpdateType utype, TocBackend & backend) const override;
81 bool forceLTR(OutputParams const &) const override;
84 /// \name Static public methods obligated for InsetCommand derived classes
87 static ParamInfo const & findInfo(std::string const &);
89 static std::string defaultCommand() { return "ref"; }
91 static bool isCompatibleCommand(std::string const & s);
94 bool outputActive() const { return active_; }
95 /// \return the command for a formatted reference to ref
96 /// \param label we're cross-referencing
97 /// \param argument for reference command
98 /// \param prefix of the label (before :)
99 /// Also used by InsetMathRef
100 static docstring getFormattedCmd(docstring const & ref, docstring & label,
101 docstring & prefix, bool use_refstyle, bool use_caps = false);
105 InsetRef(InsetRef const &);
108 /// \name Private functions inherited from Inset class
111 Inset * clone() const override { return new InsetRef(*this); }
114 /// \name Private functions inherited from InsetCommand class
117 docstring screenLabel() const override;
121 docstring displayString(docstring const & ref, std::string const & cmd,
122 std::string const & language = std::string()) const;
124 /// \return the label with things that need to be escaped escaped
125 docstring getEscapedLabel(OutputParams const &) const;
128 mutable docstring screen_label_;
130 mutable bool broken_;
132 mutable bool active_;
134 mutable docstring tooltip_;
140 #endif // INSET_REF_H