From: Abdelrazak Younes Date: Fri, 7 Mar 2008 19:46:04 +0000 (+0000) Subject: * Buffer::getLabelList(): Speed up and simplify by using the tocBackend. X-Git-Tag: 1.6.10~5808 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5da55588f2bd9f568cb5fa8554f09d52cb2329c0;p=features.git * Buffer::getLabelList(): Speed up and simplify by using the tocBackend. * 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 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 67291703c9..69dcb9395c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1352,22 +1352,18 @@ void Buffer::validate(LaTeXFeatures & features) const void Buffer::getLabelList(vector & 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()); } diff --git a/src/BufferView.cpp b/src/BufferView.cpp index c2b0d58888..73de542638 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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 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); } diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 3c188f1f32..a49feb1af5 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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 & /* list */) const {} /// describe content if cursor inside virtual void infoize(odocstream &) const {} diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index f65a9727a1..0a63d287a8 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -704,23 +704,6 @@ void InsetInclude::validate(LaTeXFeatures & features) const } -void InsetInclude::getLabelList(vector & 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())); - } -} - - void InsetInclude::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & /*di*/) const { diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index a12c114b2e..405a4c0c2f 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -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 & list) const; /** Fills \c keys * \param buffer the Buffer containing this inset. * \param keys the list of bibkeys in the child buffer. diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 96212d4b9f..3c577eb2c4 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -92,12 +92,6 @@ ParamInfo const & InsetLabel::findInfo(string const & /* cmdName */) } -void InsetLabel::getLabelList(vector & list) const -{ - list.push_back(getParam("name")); -} - - docstring InsetLabel::screenLabel() const { return screen_label_; diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 4b2d64a751..3ab79b6f28 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -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 & list) const; /// int latex(odocstream &, OutputParams const &) const; /// diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 9d60fb6f84..b8607a89f2 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -538,14 +538,6 @@ Inset::DisplayType InsetMathHull::display() const } -void InsetMathHull::getLabelList(vector & 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) diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 861d4b8722..1a0c49d056 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -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 & list) const; /// void validate(LaTeXFeatures & features) const; /// identifies HullInset