mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
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
This commit is contained in:
parent
295b84e8fb
commit
2098f1d8c2
@ -26,6 +26,7 @@
|
|||||||
#include "insets/InsetBibtex.h"
|
#include "insets/InsetBibtex.h"
|
||||||
#include "insets/InsetInclude.h"
|
#include "insets/InsetInclude.h"
|
||||||
|
|
||||||
|
#include "support/convert.h"
|
||||||
#include "support/docstream.h"
|
#include "support/docstream.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lassert.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<docstring>::const_iterator it = cited_entries_.begin();
|
||||||
|
vector<docstring>::const_iterator const en = cited_entries_.end();
|
||||||
|
int keynumber = 0;
|
||||||
|
for (; it != en; ++it) {
|
||||||
|
map<docstring, BibTeXInfo>::iterator const biit = bimap_.find(*it);
|
||||||
|
// this shouldn't happen, but...
|
||||||
|
if (biit == bimap_.end())
|
||||||
|
continue;
|
||||||
|
BibTeXInfo & entry = biit->second;
|
||||||
|
docstring const key = convert<docstring>(++keynumber);
|
||||||
|
entry.setCiteKey(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// CitationStyle
|
// CitationStyle
|
||||||
|
@ -91,6 +91,10 @@ public:
|
|||||||
///
|
///
|
||||||
docstring const & key() const { return bib_key_; }
|
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_; }
|
docstring entryType() const { return entry_type_; }
|
||||||
///
|
///
|
||||||
bool isBibTeX() const { return is_bibtex_; }
|
bool isBibTeX() const { return is_bibtex_; }
|
||||||
@ -114,6 +118,9 @@ private:
|
|||||||
docstring entry_type_;
|
docstring entry_type_;
|
||||||
/// a cache for getInfo()
|
/// a cache for getInfo()
|
||||||
mutable docstring info_;
|
mutable docstring info_;
|
||||||
|
/// key to use when citing this entry
|
||||||
|
/// currently used only by XHTML output routines
|
||||||
|
docstring cite_key_;
|
||||||
/// our map: <field, value>
|
/// our map: <field, value>
|
||||||
std::map <docstring, docstring> bimap_;
|
std::map <docstring, docstring> bimap_;
|
||||||
};
|
};
|
||||||
@ -176,6 +183,8 @@ public:
|
|||||||
/// the last name of the author.
|
/// the last name of the author.
|
||||||
std::vector<docstring> const & citedEntries() const { return cited_entries_; }
|
std::vector<docstring> const & citedEntries() const { return cited_entries_; }
|
||||||
///
|
///
|
||||||
|
void makeCitationLabels(Buffer const & buf);
|
||||||
|
///
|
||||||
const_iterator begin() const { return bimap_.begin(); }
|
const_iterator begin() const { return bimap_.begin(); }
|
||||||
///
|
///
|
||||||
void clear() { bimap_.clear(); }
|
void clear() { bimap_.clear(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user