From 656ffa10792dbd0740d6a709989baa76d523b931 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 19 Nov 2008 03:52:22 +0000 Subject: [PATCH] Fix 5538. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27633 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BiblioInfo.cpp | 34 ++++++++++++++++++++++++---------- src/BiblioInfo.h | 4 +--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 3a886c7243..dfa24ab791 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -24,9 +24,9 @@ #include "insets/InsetBibtex.h" #include "insets/InsetInclude.h" -#include "support/lassert.h" #include "support/docstream.h" #include "support/gettext.h" +#include "support/lassert.h" #include "support/lstrings.h" #include "boost/regex.hpp" @@ -95,14 +95,19 @@ docstring familyName(docstring const & name) return rtrim(fname); } - docstring const BibTeXInfo::getAbbreviatedAuthor() const { - if (!is_bibtex_) - return docstring(); - + if (!is_bibtex_) { + docstring const opt = trim(getValueForField("label")); + if (opt.empty()) + return docstring(); + + docstring authors; + split(opt, authors, '('); + return authors; + } + docstring author = getValueForField("author"); - if (author.empty()) { author = getValueForField("editor"); if (author.empty()) @@ -113,7 +118,7 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const // Try to split the author list on " and " vector const authors = getVectorFromString(author, from_ascii(" and ")); - + if (authors.size() == 2) return bformat(_("%1$s and %2$s"), familyName(authors[0]), familyName(authors[1])); @@ -127,9 +132,18 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const docstring const BibTeXInfo::getYear() const { - if (!is_bibtex_) - return docstring(); - + if (!is_bibtex_) { + docstring const opt = trim(getValueForField("label")); + if (opt.empty()) + return docstring(); + + docstring authors; + docstring const tmp = split(opt, authors, '('); + docstring year; + split(tmp, year, ')'); + return year; + } + docstring year = getValueForField("year"); if (year.empty()) year = _("No year"); diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index 98a0997a83..12e5754436 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -96,11 +96,9 @@ private: /// Class to represent a collection of bibliographical data, whether /// from BibTeX or from bibliography environments. -/// BiblioInfo.first is the bibliography key -/// BiblioInfo.second is the data for that key class BiblioInfo { public: - /// + /// bibliography key --> data for that key typedef std::map::const_iterator const_iterator; /// Returns a sorted vector of bibliography keys std::vector const getKeys() const; -- 2.39.5