}
-BiblioInfo & Buffer::masterBibInfo()
-{
- Buffer * tmp = const_cast<Buffer *>(masterBuffer());
- if (tmp != this)
- return tmp->masterBibInfo();
- return d->bibinfo_;
-}
-
-
bool Buffer::isBibInfoCacheValid() const
{
// use the master's cache
return;
d->bibinfo_.clear();
- fillWithBibKeys(d->bibinfo_);
+ collectBibKeys();
d->bibinfo_cache_valid_ = true;
}
-void Buffer::fillWithBibKeys(BiblioInfo & keys) const
+void Buffer::collectBibKeys() const
{
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
- it->fillWithBibKeys(keys, it);
+ it->collectBibKeys(it);
+}
+
+
+void Buffer::addBiblioInfo(BiblioInfo const & bi) const
+{
+ Buffer const * tmp = masterBuffer();
+ BiblioInfo & masterbi = (tmp == this) ?
+ d->bibinfo_ : tmp->d->bibinfo_;
+ masterbi.mergeBiblioInfo(bi);
+}
+
+
+void Buffer::addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const
+{
+ Buffer const * tmp = masterBuffer();
+ BiblioInfo & masterbi = (tmp == this) ?
+ d->bibinfo_ : tmp->d->bibinfo_;
+ masterbi[key] = bi;
}
namespace lyx {
class BiblioInfo;
+class BibTeXInfo;
class BufferParams;
class DispatchResult;
class DocIterator;
/// \return the bibliography information for this buffer's master,
/// or just for it, if it isn't a child.
BiblioInfo const & masterBibInfo() const;
- BiblioInfo & masterBibInfo();
- ///
- void fillWithBibKeys(BiblioInfo & keys) const;
+ /// collect bibliography info from the various insets in this buffer.
+ void collectBibKeys() const;
+ /// add some BiblioInfo to our cache
+ void addBiblioInfo(BiblioInfo const & bi) const;
+ /// add a single piece of bibliography info to our cache
+ void addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const;
///
void getLabelList(std::vector<docstring> &) const;
/// Add an entry to the TocList
/// pit is the ParConstIterator of the paragraph containing the inset
virtual void addToToc(DocIterator const &) {}
- /// Fill keys with BibTeX information
- virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const {}
+ /// Collect BibTeX information
+ virtual void collectBibKeys(InsetIterator const &) const {}
/// Update the counters of this inset and of its contents.
/// The boolean indicates whether we are preparing for output, e.g.,
/// of XHTML.
}
-void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) const
+void InsetBibitem::collectBibKeys(InsetIterator const & it) const
{
docstring const key = getParam("key");
BibTeXInfo keyvalmap(false);
DocIterator doc_it(it);
doc_it.forwardPos();
keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString();
- keys[key] = keyvalmap;
+ buffer().addBibTeXInfo(key, keyvalmap);
}
autolabel_ = from_ascii("??");
}
if (!buffer().isBibInfoCacheValid()) {
- BiblioInfo bi = buffer().masterBibInfo();
docstring const key = getParam("key");
BibTeXInfo keyvalmap(false);
keyvalmap.label(bibLabel());
keyvalmap[from_ascii("ref")] = it.paragraph().asString();
- bi[key] = keyvalmap;
+ buffer().addBibTeXInfo(key, keyvalmap);
}
}
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
- void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
+ void collectBibKeys(InsetIterator const &) const;
/// update the counter of this inset
void updateBuffer(ParIterator const &, UpdateType);
///@}
{
if (buffer().isBibInfoCacheValid())
return;
- BiblioInfo & bi = buffer().masterBibInfo();
- fillWithBibKeys(bi);
+ parseBibTeXFiles();
}
}
-void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
- InsetIterator const & /*di*/) const
+void InsetBibtex::collectBibKeys(InsetIterator const & /*di*/) const
{
- fillWithBibKeys(keylist);
+ parseBibTeXFiles();
}
-void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist) const
+void InsetBibtex::parseBibTeXFiles() const
{
// This bibtex parser is a first step to parse bibtex files
// more precisely.
// We don't restrict keys to ASCII in LyX, since our own
// InsetBibitem can generate non-ASCII keys, and nonstandard
// 8bit clean bibtex forks exist.
+
+ BiblioInfo keylist;
+
support::FileNameList const files = getBibFiles();
support::FileNameList::const_iterator it = files.begin();
support::FileNameList::const_iterator en = files.end();
} //< else (citation entry)
} //< searching '@'
} //< for loop over files
+
+ buffer().addBiblioInfo(keylist);
}
///
void updateBuffer(ParIterator const &, UpdateType);
///
- void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
+ void collectBibKeys(InsetIterator const &) const;
///
void validate(LaTeXFeatures &) const;
///
///
void editDatabases() const;
///
- void fillWithBibKeys(BiblioInfo &) const;
+ void parseBibTeXFiles() const;
/// \name Private functions inherited from Inset class
//@{
}
-void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
- InsetIterator const & /*di*/) const
+void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const
{
Buffer * child = loadIfNeeded();
if (!child)
return;
- child->fillWithBibKeys(keys);
+ child->collectBibKeys();
}
* \param keys the list of bibkeys in the child buffer.
* \param it not used here
*/
- void fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) const;
+ void collectBibKeys(InsetIterator const &) const;
///
bool hasSettings() const { return true; }
///