}
-docstring constructName(docstring const & name, string const scheme)
+docstring constructName(docstring const & name, string const & scheme)
{
// re-constructs a name from name parts according
// to a given scheme
}
-bool multipleAuthors(docstring const author)
+bool multipleAuthors(docstring const & author)
{
return getAuthors(author).size() > 1;
}
//////////////////////////////////////////////////////////////////////
BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
- : is_bibtex_(true), bib_key_(key), entry_type_(type), info_(),
+ : is_bibtex_(true), bib_key_(key), num_bib_key_(0), entry_type_(type), info_(),
modifier_(0)
{}
bit of work, however.
*/
docstring BibTeXInfo::expandFormat(docstring const & format,
- BibTeXInfoList const xrefs, int & counter, Buffer const & buf,
+ BibTeXInfoList const & xrefs, int & counter, Buffer const & buf,
CiteItem const & ci, bool next, bool second) const
{
// incorrect use of macros could put us in an infinite loop
}
-docstring const & BibTeXInfo::getInfo(BibTeXInfoList const xrefs,
+docstring const & BibTeXInfo::getInfo(BibTeXInfoList const & xrefs,
Buffer const & buf, CiteItem const & ci) const
{
bool const richtext = ci.richtext;
docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
- CiteItem const & ci, BibTeXInfoList const xrefs, size_t maxsize) const
+ CiteItem const & ci, BibTeXInfoList const & xrefs, size_t maxsize) const
{
// anything less is pointless
LASSERT(maxsize >= 16, maxsize = 16);
ret = ci.textBefore;
else if (key == "textafter")
ret = ci.textAfter;
- else if (key == "curpretext")
- ret = ci.getPretexts()[bib_key_];
- else if (key == "curposttext")
- ret = ci.getPosttexts()[bib_key_];
- else if (key == "year")
+ else if (key == "curpretext") {
+ vector<pair<docstring, docstring>> pres = ci.getPretexts();
+ vector<pair<docstring, docstring>>::iterator it = pres.begin();
+ int numkey = 1;
+ for (; it != pres.end() ; ++it) {
+ if ((*it).first == bib_key_ && numkey == num_bib_key_) {
+ ret = (*it).second;
+ pres.erase(it);
+ break;
+ }
+ if ((*it).first == bib_key_)
+ ++numkey;
+ }
+ } else if (key == "curposttext") {
+ vector<pair<docstring, docstring>> posts = ci.getPosttexts();
+ vector<pair<docstring, docstring>>::iterator it = posts.begin();
+ int numkey = 1;
+ for (; it != posts.end() ; ++it) {
+ if ((*it).first == bib_key_ && numkey == num_bib_key_) {
+ ret = (*it).second;
+ posts.erase(it);
+ break;
+ }
+ if ((*it).first == bib_key_)
+ ++numkey;
+ }
+ } else if (key == "year")
ret = getYear();
}
return docstring(_("Bibliography entry not found!"));
BibTeXInfo const & data = it->second;
BibTeXInfoList xrefptrs;
- vector<docstring> const xrefs = getXRefs(data);
for (docstring const & xref : getXRefs(data)) {
BiblioInfo::const_iterator const xrefit = find(xref);
if (xrefit != end())
LASSERT(max_size >= 16, max_size = 16);
// we can't display more than 10 of these, anyway
+ // but since we truncate in the middle,
+ // we need to split into two halfs.
bool const too_many_keys = keys.size() > 10;
- if (too_many_keys)
- keys.resize(10);
+ vector<docstring> lkeys;
+ if (too_many_keys) {
+ lkeys.insert(lkeys.end(), keys.end() - 5, keys.end());
+ keys.resize(5);
+ keys.insert(keys.end(), lkeys.begin(), lkeys.end());
+ }
CiteEngineType const engine_type = buf.params().citeEngineType();
DocumentClass const & dc = buf.params().documentClass();
docstring ret = format;
vector<docstring>::const_iterator key = keys.begin();
vector<docstring>::const_iterator ken = keys.end();
+ vector<docstring> handled_keys;
for (int i = 0; key != ken; ++key, ++i) {
+ handled_keys.push_back(*key);
+ int n = 0;
+ for (auto const k : handled_keys) {
+ if (k == *key)
+ ++n;
+ }
BiblioInfo::const_iterator it = find(*key);
BibTeXInfo empty_data;
empty_data.key(*key);
xrefptrs.push_back(&(xrefit->second));
}
}
+ data.numKey(n);
ret = data.getLabel(xrefptrs, buf, ret, ci, key + 1 != ken, i == 1);
}
- if (too_many_keys)
- ret.push_back(0x2026);//HORIZONTAL ELLIPSIS
- support::truncateWithEllipsis(ret, max_size);
+ support::truncateWithEllipsis(ret, max_size, true);
+
return ret;
}