commit d7bcab5e275ad1ec109f17a1d180bbcd1084cf98
Author: Guillaume MM <[email protected]>
Date:   Tue May 16 12:13:58 2017 +0200

    Structure the broken InsetRef status
---
 src/insets/InsetRef.cpp |   19 ++++++++++++++-----
 src/insets/InsetRef.h   |   19 ++++++++++---------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index 98fb846..7c5442c 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -339,19 +339,27 @@ void InsetRef::updateBuffer(ParIterator const & it, 
UpdateType)
                        }
                }
        }
-       
+
        if (!buffer().params().isLatex() && !getParam("name").empty()) {
                label += "||";
                label += getParam("name");
        }
-       
+
        unsigned int const maxLabelChars = 24;
        if (label.size() > maxLabelChars) {
                tooltip_ = label;
                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
diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h
index 1af1790..15f1225 100644
--- a/src/insets/InsetRef.h
+++ b/src/insets/InsetRef.h
@@ -63,7 +63,7 @@ public:
        int docbook(odocstream &, OutputParams const &) const;
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
-       /// 
+       ///
        void toString(odocstream &) const;
        ///
        void forOutliner(docstring &, size_t const, bool const) const;
@@ -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 &);
@@ -105,7 +98,13 @@ 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_;
 };
 

Reply via email to