From 2098f1d8c20d51e63e670bcdc9da8996068975bf Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 8 Jan 2010 18:19:13 +0000 Subject: [PATCH] Routines for calculating numerical labels for BibTeX citations. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32891 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BiblioInfo.cpp | 21 +++++++++++++++++++++ src/BiblioInfo.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index d8297d0303..bb9b27f7fe 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -26,6 +26,7 @@ #include "insets/InsetBibtex.h" #include "insets/InsetInclude.h" +#include "support/convert.h" #include "support/docstream.h" #include "support/gettext.h" #include "support/lassert.h" @@ -657,6 +658,26 @@ void BiblioInfo::collectCitedEntries(Buffer const & buf) } +void BiblioInfo::makeCitationLabels(Buffer const & buf) +{ + collectCitedEntries(buf); + // FIXME It'd be nice to do author-year as well as numerical + // and maybe even some other sorts of labels. + vector::const_iterator it = cited_entries_.begin(); + vector::const_iterator const en = cited_entries_.end(); + int keynumber = 0; + for (; it != en; ++it) { + map::iterator const biit = bimap_.find(*it); + // this shouldn't happen, but... + if (biit == bimap_.end()) + continue; + BibTeXInfo & entry = biit->second; + docstring const key = convert(++keynumber); + entry.setCiteKey(key); + } +} + + ////////////////////////////////////////////////////////////////////// // // CitationStyle diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index 0cb21fc0cb..658a4ad027 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -91,6 +91,10 @@ public: /// docstring const & key() const { return bib_key_; } /// + docstring citeKey() const { return cite_key_; } + /// + void setCiteKey(docstring const & k) { cite_key_ = k; } + /// docstring entryType() const { return entry_type_; } /// bool isBibTeX() const { return is_bibtex_; } @@ -114,6 +118,9 @@ private: docstring entry_type_; /// a cache for getInfo() mutable docstring info_; + /// key to use when citing this entry + /// currently used only by XHTML output routines + docstring cite_key_; /// our map: std::map bimap_; }; @@ -176,6 +183,8 @@ public: /// the last name of the author. std::vector const & citedEntries() const { return cited_entries_; } /// + void makeCitationLabels(Buffer const & buf); + /// const_iterator begin() const { return bimap_.begin(); } /// void clear() { bimap_.clear(); } -- 2.39.5