From f50c47d4be8d511e485ff6a63bd62e21e904efe9 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 11 Jun 2009 20:29:37 +0000 Subject: [PATCH] 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 --- src/BiblioInfo.cpp | 4 ++-- src/BiblioInfo.h | 10 ++++++++++ src/insets/InsetBibitem.cpp | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 32b0b64cfc..c68e18ae4c 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -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(); diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index e265045ba0..e0f8f64588 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -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, ...) diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 3a0851f8f1..c347bacfdf 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -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(); -- 2.39.5