]> git.lyx.org Git - features.git/commitdiff
* Buffer::getLabelList(): Speed up and simplify by using the tocBackend.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 7 Mar 2008 19:46:04 +0000 (19:46 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 7 Mar 2008 19:46:04 +0000 (19:46 +0000)
* Inset and derived class: get rid of getLabelList()
* BufferView::gotoLabel(): Speed up and simplify by using the tocBackend.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23541 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/BufferView.cpp
src/insets/Inset.h
src/insets/InsetInclude.cpp
src/insets/InsetInclude.h
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h

index 67291703c957637c5966af4b5d572d514a17c6db..69dcb9395c96894613d3a7442831a0343b968ecb 100644 (file)
@@ -1352,22 +1352,18 @@ void Buffer::validate(LaTeXFeatures & features) const
 
 void Buffer::getLabelList(vector<docstring> & list) const
 {
-       /// if this is a child document and the parent is already loaded
-       /// Use the parent's list instead  [ale990407]
-       Buffer const * tmp = masterBuffer();
-       if (!tmp) {
-               lyxerr << "masterBuffer() failed!" << endl;
-               BOOST_ASSERT(tmp);
-       }
-       if (tmp != this) {
-               tmp->getLabelList(list);
+       // If this is a child document, use the parent's list instead.
+       if (d->parent_buffer) {
+               masterBuffer()->getLabelList(list);
                return;
        }
 
-       updateMacros();
-
-       for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
-               it.nextInset()->getLabelList(list);
+       list.clear();
+       Toc & toc = d->toc_backend.toc("label");
+       TocIterator toc_it = toc.begin();
+       TocIterator end = toc.end();
+       for (; toc_it != end; ++toc_it)
+               list.push_back(toc_it->str());
 }
 
 
index c2b0d588887ff9ed64e3b4a848aa3f37a7053bb5..73de5426381d5d24374b8f9ca94f9de250413f24 100644 (file)
@@ -49,6 +49,7 @@
 #include "TextClass.h"
 #include "TextMetrics.h"
 #include "TexRow.h"
+#include "TocBackend.h"
 #include "VSpace.h"
 #include "WordLangTuple.h"
 
@@ -1609,15 +1610,15 @@ void BufferView::setCursorFromRow(int row)
 
 void BufferView::gotoLabel(docstring const & label)
 {
-       for (InsetIterator it = inset_iterator_begin(buffer_.inset()); it; ++it) {
-               vector<docstring> labels;
-               it->getLabelList(labels);
-               if (std::find(labels.begin(), labels.end(), label) != labels.end()) {
-                       setCursor(it);
-                       showCursor();
-                       return;
-               }
+       Toc & toc = buffer().tocBackend().toc("label");
+       TocIterator toc_it = toc.begin();
+       TocIterator end = toc.end();
+       for (; toc_it != end; ++toc_it) {
+               if (label == toc_it->str())
+                       dispatch(toc_it->action());
        }
+       //FIXME: We could do a bit more searching thanks to this:
+       //InsetLabel const * inset = buffer_.insetLabel(label);
 }
 
 
index 3c188f1f325f6fb153f45501d025f377cba6636e..a49feb1af516b5344e225ed24d301fe9ae21205d 100644 (file)
@@ -256,8 +256,6 @@ public:
 
        /// request "external features"
        virtual void validate(LaTeXFeatures &) const {}
-       /// Appends \c list with all labels found within this inset.
-       virtual void getLabelList(std::vector<docstring> & /* list */) const {}
 
        /// describe content if cursor inside
        virtual void infoize(odocstream &) const {}
index f65a9727a1029bc319c330f07a98117a0c53a103..0a63d287a8562673433febd85645634ae8ecfea7 100644 (file)
@@ -704,23 +704,6 @@ void InsetInclude::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetInclude::getLabelList(vector<docstring> & list) const
-{
-       if (isListings(params()) && label_) {
-               label_->getLabelList(list);
-               return;
-       }
-       
-       if (loadIfNeeded(buffer(), params())) {
-               string const included_file = includedFilename(buffer(), params()).absFilename();
-               Buffer * tmp = theBufferList().getBuffer(included_file);
-               tmp->setParent(0);
-               tmp->getLabelList(list);
-               tmp->setParent(const_cast<Buffer *>(&buffer()));
-       }
-}
-
-
 void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
        InsetIterator const & /*di*/) const
 {
index a12c114b2eeb8f7e314e64665298ac38ff9c1602..405a4c0c2f5765b0540c22a2f3be2f6980aa2e1d 100644 (file)
@@ -48,11 +48,6 @@ public:
        DisplayType display() const;
        ///
        InsetCode lyxCode() const { return INCLUDE_CODE; }
-       /** Fills \c list
-        *  \param buffer the Buffer containing this inset.
-        *  \param list the list of labels in the child buffer.
-        */
-       void getLabelList(std::vector<docstring> & list) const;
        /** Fills \c keys
         *  \param buffer the Buffer containing this inset.
         *  \param keys the list of bibkeys in the child buffer.
index 96212d4b9f3f46ba299cabcba28b7527d243184b..3c577eb2c4002f048520a70be8f1acb7c6b778cf 100644 (file)
@@ -92,12 +92,6 @@ ParamInfo const & InsetLabel::findInfo(string const & /* cmdName */)
 }
 
 
-void InsetLabel::getLabelList(vector<docstring> & list) const
-{
-       list.push_back(getParam("name"));
-}
-
-
 docstring InsetLabel::screenLabel() const
 {
        return screen_label_;
index 4b2d64a751d3ceb00eb8ee9dda7563b6203baa09..3ab79b6f2825c7194d573d6573738325c7d0079d 100644 (file)
@@ -34,8 +34,6 @@ public:
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        InsetCode lyxCode() const { return LABEL_CODE; }
-       /// Appends \c list with this label
-       void getLabelList(std::vector<docstring> & list) const;
        ///
        int latex(odocstream &, OutputParams const &) const;
        ///
index 9d60fb6f843ec1e432ef740fefde9457402e706b..b8607a89f2b3fa5656852ce2f299579fa1ff5a6e 100644 (file)
@@ -538,14 +538,6 @@ Inset::DisplayType InsetMathHull::display() const
 }
 
 
-void InsetMathHull::getLabelList(vector<docstring> & labels) const
-{
-       for (row_type row = 0; row < nrows(); ++row)
-               if (label_[row] && !nonum_[row])
-                       labels.push_back(label_[row]->screenLabel());
-}
-
-
 bool InsetMathHull::numberedType() const
 {
        if (type_ == hullNone)
index 861d4b87227c8dbc74ec4aaf7a3f192b88878a2e..1a0c49d05640fd8de4fb60570e5815cc3b445240 100644 (file)
@@ -63,8 +63,6 @@ public:
        bool numberedType() const;
        ///
        bool ams() const;
-       /// Appends \c list with all labels found within this inset.
-       void getLabelList(std::vector<docstring> & list) const;
        ///
        void validate(LaTeXFeatures & features) const;
        /// identifies HullInset