* 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
This commit is contained in:
Abdelrazak Younes 2008-03-07 19:46:04 +00:00
parent f0771cecc2
commit 5da55588f2
9 changed files with 18 additions and 63 deletions

View 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());
}

View 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);
}

View 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 {}

View 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
{

View 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.

View 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_;

View 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;
///

View 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)

View 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