4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
15 #include "InsetCommand.h"
20 class InsetLabel : public InsetCommand
24 InsetLabel(Buffer * buf, InsetCommandParams const &);
27 docstring const & activeCounter() const { return active_counter_; }
29 docstring const & counterValue() const { return counter_value_; }
31 docstring const & prettyCounter() const { return pretty_counter_; }
33 docstring const & formattedCounter() const { return formatted_counter_; }
35 void setCounterValue(docstring cv) { counter_value_ = cv; }
37 void setPrettyCounter(docstring pc) { pretty_counter_ = pc; }
39 void setFormattedCounter(docstring fc) { formatted_counter_ = fc; }
41 int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
42 /// Updates only the label string, doesn't handle undo nor references.
43 void updateLabel(docstring const & new_label, bool const active = true);
44 /// Updates the label and the references to it.
45 /// Will also handle undo/redo if \p cursor is passed.
46 void updateLabelAndRefs(docstring const & new_label, Cursor * cursor = 0);
48 /// \name Public functions inherited from Inset class
50 /// verify label and update references.
51 void initView() override;
53 bool isLabeled() const override { return true; }
55 bool hasSettings() const override { return true; }
57 InsetCode lyxCode() const override { return LABEL_CODE; }
59 void latex(otexstream & os, OutputParams const & runparams_in) 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 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;
72 /// Is the content of this inset part of the immediate (visible) text sequence?
73 bool isPartOfTextSequence() const override { return false; }
75 bool inheritFont() const override { return false; }
78 /// \name Static public methods obligated for InsetCommand derived classes
81 static ParamInfo const & findInfo(std::string const &);
83 static std::string defaultCommand() { return "label"; }
85 static bool isCompatibleCommand(std::string const & s)
86 { return s == "label"; }
90 /// \name Private functions inherited from InsetCommand class
93 docstring screenLabel() const override;
97 /// \name Private functions inherited from Inset class
100 Inset * clone() const override { return new InsetLabel(*this); }
102 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const override;
104 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
108 void uniqueLabel(docstring & label) const;
110 void updateReferences(docstring const & old_label,
111 docstring const & new_label, bool const changes);
113 docstring screen_label_;
115 docstring active_counter_;
117 docstring counter_value_;
119 docstring pretty_counter_;
121 docstring formatted_counter_;