From 62df753a2e70a2f05e72d59ecb79daf44f1673d2 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 18 Sep 2003 20:18:39 +0000 Subject: [PATCH] Pass Buffer arg to Inset::getLabelList, Inset::fillWithBibKeys. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7794 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 2 +- src/ChangeLog | 7 +++++++ src/buffer.C | 23 ++++++++++++++--------- src/insets/ChangeLog | 10 ++++++++++ src/insets/insetbase.h | 6 ++++-- src/insets/insetcollapsable.C | 5 +++-- src/insets/insetcollapsable.h | 4 ++-- src/insets/insetinclude.C | 5 +++-- src/insets/insetinclude.h | 23 ++++++++++++++++------- src/insets/insetlabel.C | 2 +- src/insets/insetlabel.h | 4 ++-- src/insets/insettabular.C | 5 +++-- src/insets/insettabular.h | 4 ++-- src/insets/insettext.C | 5 +++-- src/insets/insettext.h | 4 ++-- src/mathed/ChangeLog | 6 ++++++ src/mathed/formula.C | 5 +++-- src/mathed/formula.h | 5 +++-- src/mathed/math_hullinset.C | 3 ++- src/mathed/math_hullinset.h | 5 +++-- src/tabular.C | 5 +++-- src/tabular.h | 4 ++-- 22 files changed, 95 insertions(+), 47 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 54d25dbb15..6eab513d29 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -324,7 +324,7 @@ void BufferView::gotoLabel(string const & label) for (Buffer::inset_iterator it = buffer()->inset_iterator_begin(); it != buffer()->inset_iterator_end(); ++it) { vector labels; - it->getLabelList(labels); + it->getLabelList(*buffer(), labels); if (find(labels.begin(),labels.end(),label) != labels.end()) { beforeChange(text); text->setCursor(it.getPar(), it.getPos()); diff --git a/src/ChangeLog b/src/ChangeLog index 240932eb56..6d176fa6dc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-09-18 Angus Leeming + + * buffer.C: + * BufferView.C: pass the buffer when calling Inset::getLabelList, + Inset::fillWithBibKeys. + * tabular.[Ch] (getLabelList): receive, pass on a Buffer const & arg. + 2003-09-18 Angus Leeming * LaTeXFeatures.[Ch]: append a '_' to the names of all private member diff --git a/src/buffer.C b/src/buffer.C index 8bdf819992..2a080bc442 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2140,7 +2140,7 @@ void Buffer::getLabelList(std::vector & list) const for (inset_iterator it = inset_const_iterator_begin(); it != inset_const_iterator_end(); ++it) { - it->getLabelList(list); + it->getLabelList(*this, list); } } @@ -2161,14 +2161,19 @@ void Buffer::fillWithBibKeys(std::vector > & keys) con for (inset_iterator it = inset_const_iterator_begin(); it != inset_const_iterator_end(); ++it) { - if (it->lyxCode() == InsetOld::BIBTEX_CODE) - static_cast(*it).fillWithBibKeys(*this, keys); - else if (it->lyxCode() == InsetOld::INCLUDE_CODE) - static_cast(*it).fillWithBibKeys(keys); - else if (it->lyxCode() == InsetOld::BIBITEM_CODE) { - InsetBibitem & bib = static_cast(*it); - string const key = bib.getContents(); - string const opt = bib.getOptions(); + if (it->lyxCode() == InsetOld::BIBTEX_CODE) { + InsetBibtex const & inset = + dynamic_cast(*it); + inset.fillWithBibKeys(*this, keys); + } else if (it->lyxCode() == InsetOld::INCLUDE_CODE) { + InsetInclude const & inset = + dynamic_cast(*it); + inset.fillWithBibKeys(*this, keys); + } else if (it->lyxCode() == InsetOld::BIBITEM_CODE) { + InsetBibitem const & inset = + dynamic_cast(*it); + string const key = inset.getContents(); + string const opt = inset.getOptions(); string const ref; // = pit->asString(this, false); string const info = opt + "TheBibliographyRef" + ref; keys.push_back(pair(key, info)); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index b4a8d8dad5..1d19d84766 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2003-09-18 Angus Leeming + + * insetinsetbase.h (getLabelList): + * insetinsetcollapsable.[Ch] (getLabelList): + * insetinsetinclude.[Ch] (getLabelList): + * insetinsetlabel.[Ch] (getLabelList): + * insetinsettabular.[Ch] (getLabelList): + * insetinsettext.[Ch] (getLabelList): receive a Buffer const & arg. + * insetinsetinclude.[Ch] (fillWithBibKeys): ditto. + 2003-09-18 Angus Leeming * insetinclude.[Ch]: remove Params::operator==, operator!= as they're diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index f5eecdbdfa..039c0ebd84 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -17,6 +17,7 @@ #include #include +class Buffer; class BufferView; class FuncRequest; class MetricsInfo; @@ -101,8 +102,9 @@ public: virtual BufferView * view() const { return 0; } /// request "external features" virtual void validate(LaTeXFeatures &) const {} - /// fill in all labels in the inset - virtual void getLabelList(std::vector &) const {} + /// Appends \c list with all labels found within this inset. + virtual void getLabelList(Buffer const &, + std::vector & /* list */) const {} }; #endif diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 0745ae1f0a..f6e4ccd06b 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -435,9 +435,10 @@ void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const } -void InsetCollapsable::getLabelList(std::vector & list) const +void InsetCollapsable::getLabelList(Buffer const & buffer, + std::vector & list) const { - inset.getLabelList(list); + inset.getLabelList(buffer, list); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 9c0b2f6af3..1ead924b0a 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -107,8 +107,8 @@ public: LyXText * getLyXText(BufferView const *, bool const recursive) const; /// void deleteLyXText(BufferView *, bool recursive=true) const; - /// - void getLabelList(std::vector &) const; + /// Appends \c list with all labels found within this inset. + void getLabelList(Buffer const &, std::vector & list) const; /// int scroll(bool recursive=true) const; /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index ce51bc5eb1..b638c1958a 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -504,7 +504,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const } -void InsetInclude::getLabelList(std::vector & list) const +void InsetInclude::getLabelList(Buffer const &, std::vector & list) const { if (loadIfNeeded()) { Buffer * tmp = bufferlist.getBuffer(getFileName()); @@ -515,7 +515,8 @@ void InsetInclude::getLabelList(std::vector & list) const } -void InsetInclude::fillWithBibKeys(std::vector > & keys) const +void InsetInclude::fillWithBibKeys(Buffer const &, + std::vector > & keys) const { if (loadIfNeeded()) { Buffer * tmp = bufferlist.getBuffer(getFileName()); diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 92323646fb..b08010c063 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -62,10 +62,19 @@ public: virtual std::auto_ptr clone() const; /// InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; } - /// This returns the list of labels on the child buffer - void getLabelList(std::vector &) const; - /// This returns the list of bibkeys on the child buffer - void fillWithBibKeys(std::vector > & keys) const; + /** Fills \c list + * \param buffer the Buffer containing this inset. + * \param list the list of labels in the child buffer. + */ + void getLabelList(Buffer const & buffer, + std::vector & list) const; + /** Fills \c keys + * \param buffer the Buffer containing this inset. + * \param keys the list of bibkeys in the child buffer. + */ + /// + void fillWithBibKeys(Buffer const & buffer, + std::vector > & keys) const; /// EDITABLE editable() const { @@ -87,15 +96,15 @@ public: /// void validate(LaTeXFeatures &) const; - /// return true if the file is or got loaded. - bool loadIfNeeded() const; - /// void addPreview(lyx::graphics::PreviewLoader &) const; private: friend class InsetIncludeMailer; + /// return true if the file is or got loaded. + bool loadIfNeeded() const; + /// void write(std::ostream &) const; /// diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index fd61661139..0d7e33f040 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -33,7 +33,7 @@ InsetLabel::~InsetLabel() } -void InsetLabel::getLabelList(std::vector & list) const +void InsetLabel::getLabelList(Buffer const &, std::vector & list) const { list.push_back(getContents()); } diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index 60af5c7f6b..805004f0ac 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -33,8 +33,8 @@ public: EDITABLE editable() const { return IS_EDITABLE; } /// InsetOld::Code lyxCode() const { return InsetOld::LABEL_CODE; } - /// - void getLabelList(std::vector &) const; + /// Appends \c list with this label + void getLabelList(Buffer const &, std::vector & list) const; /// int latex(Buffer const &, std::ostream &, LatexRunParams const &) const; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index fb03637610..9d82512403 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2185,9 +2185,10 @@ FuncStatus InsetTabular::getStatus(string const & what) const } -void InsetTabular::getLabelList(std::vector & list) const +void InsetTabular::getLabelList(Buffer const & buffer, + std::vector & list) const { - tabular.getLabelList(list); + tabular.getLabelList(buffer, list); } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 372c42efb1..490885c01b 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -145,8 +145,8 @@ public: bool showInsetDialog(BufferView *) const; /// FuncStatus getStatus(string const & argument) const; - /// - void getLabelList(std::vector &) const; + /// Appends \c list with all labels found within this inset. + void getLabelList(Buffer const &, std::vector & list) const; /// int scroll(bool recursive=true) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 83b8baeb8d..d2872a07b9 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1318,7 +1318,8 @@ bool InsetText::showInsetDialog(BufferView * bv) const } -void InsetText::getLabelList(std::vector & list) const +void InsetText::getLabelList(Buffer const & buffer, + std::vector & list) const { ParagraphList::const_iterator pit = paragraphs.begin(); ParagraphList::const_iterator pend = paragraphs.end(); @@ -1326,7 +1327,7 @@ void InsetText::getLabelList(std::vector & list) const InsetList::const_iterator beg = pit->insetlist.begin(); InsetList::const_iterator end = pit->insetlist.end(); for (; beg != end; ++beg) - beg->inset->getLabelList(list); + beg->inset->getLabelList(buffer, list); } } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index d110d619cf..9edd348baa 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -139,8 +139,8 @@ public: void deleteLyXText(BufferView *, bool recursive = true) const; /// bool showInsetDialog(BufferView *) const; - /// - void getLabelList(std::vector &) const; + /// Appends \c list with all labels found within this inset. + void getLabelList(Buffer const &, std::vector & list) const; /// int scroll(bool recursive = true) const; /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index bbdc3cb077..877e2eb813 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,9 @@ +2003-09-18 Angus Leeming + + * matheformula.[Ch] (getLabelList): + * mathemath_hullinset.[Ch] (getLabelList): + receive a Buffer const & arg. + 2003-09-18 Angus Leeming * formula.C (latexString): add a Buffer const & arg. diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 36b39d32fd..4e7e118bcc 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -228,9 +228,10 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const } -void InsetFormula::getLabelList(vector & res) const +void InsetFormula::getLabelList(Buffer const & buffer, + vector & res) const { - par()->getLabelList(res); + par()->getLabelList(buffer, res); } diff --git a/src/mathed/formula.h b/src/mathed/formula.h index f2b3e2fe69..0af46fa6eb 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -59,8 +59,9 @@ public: InsetOld::Code lyxCode() const; /// bool insetAllowed(InsetOld::Code code) const; - /// - void getLabelList(std::vector &) const; + /// Appends \c list with all labels found within this inset. + void getLabelList(Buffer const &, + std::vector & list) const; /// MathAtom const & par() const { return par_; } /// diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 3cf949d4fa..8d0b6b6202 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -308,7 +308,8 @@ bool MathHullInset::display() const } -void MathHullInset::getLabelList(std::vector & labels) const +void MathHullInset::getLabelList(Buffer const &, + std::vector & labels) const { for (row_type row = 0; row < nrows(); ++row) if (!label_[row].empty() && nonum_[row] != 1) diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index 6c9237351a..4de81929c1 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -52,8 +52,9 @@ public: bool ams() const; /// local dispatcher dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos); - /// - void getLabelList(std::vector &) const; + /// Appends \c list with all labels found within this inset. + void getLabelList(Buffer const &, + std::vector & list) const; /// void validate(LaTeXFeatures & features) const; /// identifies MatrixInsets diff --git a/src/tabular.C b/src/tabular.C index ce073eb463..006edbd3ea 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2656,11 +2656,12 @@ void LyXTabular::validate(LaTeXFeatures & features) const } -void LyXTabular::getLabelList(std::vector & list) const +void LyXTabular::getLabelList(Buffer const & buffer, + std::vector & list) const { for (int i = 0; i < rows_; ++i) for (int j = 0; j < columns_; ++j) - getCellInset(i, j).getLabelList(list); + getCellInset(i, j).getLabelList(buffer, list); } diff --git a/src/tabular.h b/src/tabular.h index c2ac148da6..211daf0b4f 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -377,8 +377,8 @@ public: int columns() const { return columns_;} /// void validate(LaTeXFeatures &) const; - /// - void getLabelList(std::vector &) const; + /// Appends \c list with all labels found within this inset. + void getLabelList(Buffer const &, std::vector & list) const; /// /// recalculate the widths/heights only! void reinit(); -- 2.39.2