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
This commit is contained in:
Angus Leeming 2003-09-18 20:18:39 +00:00
parent 9252f9886a
commit 62df753a2e
22 changed files with 95 additions and 47 deletions

View File

@ -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<string> 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());

View File

@ -1,3 +1,10 @@
2003-09-18 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org>
* LaTeXFeatures.[Ch]: append a '_' to the names of all private member

View File

@ -2140,7 +2140,7 @@ void Buffer::getLabelList(std::vector<string> & 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<std::pair<string, string> > & keys) con
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it) {
if (it->lyxCode() == InsetOld::BIBTEX_CODE)
static_cast<InsetBibtex &>(*it).fillWithBibKeys(*this, keys);
else if (it->lyxCode() == InsetOld::INCLUDE_CODE)
static_cast<InsetInclude &>(*it).fillWithBibKeys(keys);
else if (it->lyxCode() == InsetOld::BIBITEM_CODE) {
InsetBibitem & bib = static_cast<InsetBibitem &>(*it);
string const key = bib.getContents();
string const opt = bib.getOptions();
if (it->lyxCode() == InsetOld::BIBTEX_CODE) {
InsetBibtex const & inset =
dynamic_cast<InsetBibtex const &>(*it);
inset.fillWithBibKeys(*this, keys);
} else if (it->lyxCode() == InsetOld::INCLUDE_CODE) {
InsetInclude const & inset =
dynamic_cast<InsetInclude const &>(*it);
inset.fillWithBibKeys(*this, keys);
} else if (it->lyxCode() == InsetOld::BIBITEM_CODE) {
InsetBibitem const & inset =
dynamic_cast<InsetBibitem const &>(*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<string, string>(key, info));

View File

@ -1,3 +1,13 @@
2003-09-18 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org>
* insetinclude.[Ch]: remove Params::operator==, operator!= as they're

View File

@ -17,6 +17,7 @@
#include <vector>
#include <memory>
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<string> &) const {}
/// Appends \c list with all labels found within this inset.
virtual void getLabelList(Buffer const &,
std::vector<string> & /* list */) const {}
};
#endif

View File

@ -435,9 +435,10 @@ void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
}
void InsetCollapsable::getLabelList(std::vector<string> & list) const
void InsetCollapsable::getLabelList(Buffer const & buffer,
std::vector<string> & list) const
{
inset.getLabelList(list);
inset.getLabelList(buffer, list);
}

View File

@ -107,8 +107,8 @@ public:
LyXText * getLyXText(BufferView const *, bool const recursive) const;
///
void deleteLyXText(BufferView *, bool recursive=true) const;
///
void getLabelList(std::vector<string> &) const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &, std::vector<string> & list) const;
///
int scroll(bool recursive=true) const;
///

View File

@ -504,7 +504,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
}
void InsetInclude::getLabelList(std::vector<string> & list) const
void InsetInclude::getLabelList(Buffer const &, std::vector<string> & list) const
{
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
@ -515,7 +515,8 @@ void InsetInclude::getLabelList(std::vector<string> & list) const
}
void InsetInclude::fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const
void InsetInclude::fillWithBibKeys(Buffer const &,
std::vector<std::pair<string,string> > & keys) const
{
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());

View File

@ -62,10 +62,19 @@ public:
virtual std::auto_ptr<InsetBase> clone() const;
///
InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
/// This returns the list of labels on the child buffer
void getLabelList(std::vector<string> &) const;
/// This returns the list of bibkeys on the child buffer
void fillWithBibKeys(std::vector<std::pair<string,string> > & 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<string> & 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<std::pair<string,string> > & 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;
///

View File

@ -33,7 +33,7 @@ InsetLabel::~InsetLabel()
}
void InsetLabel::getLabelList(std::vector<string> & list) const
void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
{
list.push_back(getContents());
}

View File

@ -33,8 +33,8 @@ public:
EDITABLE editable() const { return IS_EDITABLE; }
///
InsetOld::Code lyxCode() const { return InsetOld::LABEL_CODE; }
///
void getLabelList(std::vector<string> &) const;
/// Appends \c list with this label
void getLabelList(Buffer const &, std::vector<string> & list) const;
///
int latex(Buffer const &, std::ostream &,
LatexRunParams const &) const;

View File

@ -2185,9 +2185,10 @@ FuncStatus InsetTabular::getStatus(string const & what) const
}
void InsetTabular::getLabelList(std::vector<string> & list) const
void InsetTabular::getLabelList(Buffer const & buffer,
std::vector<string> & list) const
{
tabular.getLabelList(list);
tabular.getLabelList(buffer, list);
}

View File

@ -145,8 +145,8 @@ public:
bool showInsetDialog(BufferView *) const;
///
FuncStatus getStatus(string const & argument) const;
///
void getLabelList(std::vector<string> &) const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &, std::vector<string> & list) const;
///
int scroll(bool recursive=true) const;
///

View File

@ -1318,7 +1318,8 @@ bool InsetText::showInsetDialog(BufferView * bv) const
}
void InsetText::getLabelList(std::vector<string> & list) const
void InsetText::getLabelList(Buffer const & buffer,
std::vector<string> & list) const
{
ParagraphList::const_iterator pit = paragraphs.begin();
ParagraphList::const_iterator pend = paragraphs.end();
@ -1326,7 +1327,7 @@ void InsetText::getLabelList(std::vector<string> & 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);
}
}

View File

@ -139,8 +139,8 @@ public:
void deleteLyXText(BufferView *, bool recursive = true) const;
///
bool showInsetDialog(BufferView *) const;
///
void getLabelList(std::vector<string> &) const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &, std::vector<string> & list) const;
///
int scroll(bool recursive = true) const;
///

View File

@ -1,3 +1,9 @@
2003-09-18 Angus Leeming <leeming@lyx.org>
* matheformula.[Ch] (getLabelList):
* mathemath_hullinset.[Ch] (getLabelList):
receive a Buffer const & arg.
2003-09-18 Angus Leeming <leeming@lyx.org>
* formula.C (latexString): add a Buffer const & arg.

View File

@ -228,9 +228,10 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
}
void InsetFormula::getLabelList(vector<string> & res) const
void InsetFormula::getLabelList(Buffer const & buffer,
vector<string> & res) const
{
par()->getLabelList(res);
par()->getLabelList(buffer, res);
}

View File

@ -59,8 +59,9 @@ public:
InsetOld::Code lyxCode() const;
///
bool insetAllowed(InsetOld::Code code) const;
///
void getLabelList(std::vector<string> &) const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &,
std::vector<string> & list) const;
///
MathAtom const & par() const { return par_; }
///

View File

@ -308,7 +308,8 @@ bool MathHullInset::display() const
}
void MathHullInset::getLabelList(std::vector<string> & labels) const
void MathHullInset::getLabelList(Buffer const &,
std::vector<string> & labels) const
{
for (row_type row = 0; row < nrows(); ++row)
if (!label_[row].empty() && nonum_[row] != 1)

View File

@ -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<string> &) const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &,
std::vector<string> & list) const;
///
void validate(LaTeXFeatures & features) const;
/// identifies MatrixInsets

View File

@ -2656,11 +2656,12 @@ void LyXTabular::validate(LaTeXFeatures & features) const
}
void LyXTabular::getLabelList(std::vector<string> & list) const
void LyXTabular::getLabelList(Buffer const & buffer,
std::vector<string> & 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);
}

View File

@ -377,8 +377,8 @@ public:
int columns() const { return columns_;}
///
void validate(LaTeXFeatures &) const;
///
void getLabelList(std::vector<string> &) const;
/// Appends \c list with all labels found within this inset.
void getLabelList(Buffer const &, std::vector<string> & list) const;
///
/// recalculate the widths/heights only!
void reinit();