Structure the broken InsetRef status

This commit is contained in:
Guillaume MM 2017-05-16 12:13:58 +02:00
parent d870a0f2fd
commit d7bcab5e27
2 changed files with 24 additions and 14 deletions

View File

@ -351,7 +351,15 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
support::truncateWithEllipsis(label, maxLabelChars);
} else
tooltip_ = from_ascii("");
screen_label_ = label;
broken_ = false;
}
docstring InsetRef::screenLabel() const
{
return (broken_ ? _("BROKEN: ") : docstring()) + screen_label_;
}
@ -364,9 +372,10 @@ void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
return;
// It seems that this reference does not point to any valid label.
screen_label_ = _("BROKEN: ") + screen_label_;
broken_ = true;
shared_ptr<Toc> toc = backend.toc("label");
toc->push_back(TocItem(cpit, 0, screen_label_, output_active));
toc->push_back(TocItem(cpit, 0, screenLabel(), output_active));
}
@ -435,7 +444,7 @@ string const & InsetRef::getName(int type)
docstring InsetRef::getTOCString() const
{
return tooltip_.empty() ? screen_label_ : tooltip_;
return tooltip_.empty() ? screenLabel() : tooltip_;
}
} // namespace lyx

View File

@ -88,13 +88,6 @@ public:
static bool isCompatibleCommand(std::string const & s);
//@}
//FIXME: private
/// \name Private functions inherited from InsetCommand class
//@{
///
docstring screenLabel() const { return screen_label_; }
//@}
protected:
///
InsetRef(InsetRef const &);
@ -106,6 +99,12 @@ private:
Inset * clone() const { return new InsetRef(*this); }
//@}
/// \name Private functions inherited from InsetCommand class
//@{
///
docstring screenLabel() const;
//@}
/// \return the label with things that need to be escaped escaped
docstring getEscapedLabel(OutputParams const &) const;
/// \return the command for a formatted reference to ref
@ -118,6 +117,8 @@ private:
///
mutable docstring screen_label_;
///
mutable bool broken_;
///
mutable docstring tooltip_;
};