Introduce a field for keeping track of the citation label.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30047 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-06-11 20:29:37 +00:00
parent d832613cac
commit f50c47d4be
3 changed files with 13 additions and 3 deletions

View File

@ -208,7 +208,7 @@ bool BibTeXInfo::hasField(docstring const & field) const
docstring const BibTeXInfo::getAbbreviatedAuthor() const
{
if (!is_bibtex_) {
docstring const opt = trim(operator[]("label"));
docstring const opt = label();
if (opt.empty())
return docstring();
@ -245,7 +245,7 @@ docstring const BibTeXInfo::getYear() const
if (is_bibtex_)
return operator[]("year");
docstring const opt = trim(operator[]("label"));
docstring const opt = label();
if (opt.empty())
return docstring();

View File

@ -85,6 +85,12 @@ public:
///
void setAllData(docstring const & d) { all_data_ = d; }
///
void label(docstring const & d) { label_= d; }
///
docstring const & label() const { return label_; }
///
docstring const & key() const { return bib_key_; }
///
docstring entryType() const { return entry_type_; }
private:
/// like operator[], except, if the field is empty, it will attempt
@ -96,6 +102,10 @@ private:
bool is_bibtex_;
/// the BibTeX key for this entry
docstring bib_key_;
/// the label that will appear in citations
/// this is easily set from bibliography environments, but has
/// to be calculated for entries we get from BibTeX
docstring label_;
/// a single string containing all BibTeX data associated with this key
docstring all_data_;
/// the BibTeX entry type (article, book, incollection, ...)

View File

@ -244,7 +244,7 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it)
{
docstring const key = getParam("key");
BibTeXInfo keyvalmap(false);
keyvalmap[from_ascii("label")] = getParam("label");
keyvalmap.label(trim(getParam("label")));
DocIterator doc_it(it);
doc_it.forwardPos();
keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString();