2007-08-14 16:50:51 +00:00
|
|
|
|
/**
|
2007-08-20 16:30:02 +00:00
|
|
|
|
* \file BiblioInfo.cpp
|
2007-08-14 16:50:51 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2007-08-20 16:30:02 +00:00
|
|
|
|
* \author Richard Heck
|
2007-08-14 16:50:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-08-14 22:18:27 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-08-20 17:04:36 +00:00
|
|
|
|
#include "BiblioInfo.h"
|
2007-08-20 16:30:02 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
2007-08-15 08:57:58 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2009-01-17 15:55:32 +00:00
|
|
|
|
#include "Encoding.h"
|
2007-08-14 16:50:51 +00:00
|
|
|
|
#include "InsetIterator.h"
|
|
|
|
|
#include "Paragraph.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/Inset.h"
|
|
|
|
|
#include "insets/InsetBibitem.h"
|
|
|
|
|
#include "insets/InsetBibtex.h"
|
|
|
|
|
#include "insets/InsetInclude.h"
|
|
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
|
#include "support/docstream.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2008-11-19 16:39:16 +00:00
|
|
|
|
#include "support/lassert.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2009-01-12 15:30:26 +00:00
|
|
|
|
#include "support/textutils.h"
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
2007-08-14 22:18:27 +00:00
|
|
|
|
#include "boost/regex.hpp"
|
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
|
using namespace lyx::support;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
2007-11-05 20:33:20 +00:00
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
namespace lyx {
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
namespace {
|
2007-08-16 01:59:20 +00:00
|
|
|
|
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
// gets the "family name" from an author-type string
|
2008-04-25 20:03:03 +00:00
|
|
|
|
docstring familyName(docstring const & name)
|
2007-11-05 20:33:20 +00:00
|
|
|
|
{
|
|
|
|
|
if (name.empty())
|
|
|
|
|
return docstring();
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
2009-01-12 15:30:26 +00:00
|
|
|
|
// first we look for a comma, and take the last name to be everything
|
|
|
|
|
// preceding the right-most one, so that we also get the "jr" part.
|
|
|
|
|
docstring::size_type idx = name.rfind(',');
|
2007-11-05 20:33:20 +00:00
|
|
|
|
if (idx != docstring::npos)
|
2009-01-12 15:30:26 +00:00
|
|
|
|
return ltrim(name.substr(0, idx));
|
|
|
|
|
|
|
|
|
|
// OK, so now we want to look for the last name. We're going to
|
|
|
|
|
// include the "von" part. This isn't perfect.
|
|
|
|
|
// Split on spaces, to get various tokens.
|
|
|
|
|
vector<docstring> pieces = getVectorFromString(name, from_ascii(" "));
|
|
|
|
|
// If we only get two, assume the last one is the last name
|
|
|
|
|
if (pieces.size() <= 2)
|
|
|
|
|
return pieces.back();
|
|
|
|
|
|
|
|
|
|
// Now we look for the first token that begins with a lower case letter.
|
|
|
|
|
vector<docstring>::const_iterator it = pieces.begin();
|
|
|
|
|
vector<docstring>::const_iterator en = pieces.end();
|
|
|
|
|
for (; it != en; ++it) {
|
|
|
|
|
if ((*it).size() == 0)
|
|
|
|
|
continue;
|
|
|
|
|
char_type const c = (*it)[0];
|
|
|
|
|
if (isLower(c))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (it == en) // we never found a "von"
|
|
|
|
|
return pieces.back();
|
|
|
|
|
|
|
|
|
|
// reconstruct what we need to return
|
|
|
|
|
docstring retval;
|
|
|
|
|
bool first = true;
|
|
|
|
|
for (; it != en; ++it) {
|
|
|
|
|
if (!first)
|
|
|
|
|
retval += " ";
|
|
|
|
|
else
|
|
|
|
|
first = false;
|
|
|
|
|
retval += *it;
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
2007-11-05 20:33:20 +00:00
|
|
|
|
}
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
2008-11-19 16:39:16 +00:00
|
|
|
|
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
// converts a string containing LaTeX commands into unicode
|
|
|
|
|
// for display.
|
|
|
|
|
docstring convertLaTeXCommands(docstring const & str)
|
2009-01-17 15:55:32 +00:00
|
|
|
|
{
|
|
|
|
|
docstring val = str;
|
|
|
|
|
docstring ret;
|
|
|
|
|
|
|
|
|
|
bool scanning_cmd = false;
|
|
|
|
|
bool scanning_math = false;
|
|
|
|
|
bool escaped = false; // used to catch \$, etc.
|
|
|
|
|
while (val.size()) {
|
|
|
|
|
char_type const ch = val[0];
|
|
|
|
|
|
|
|
|
|
// if we're scanning math, we output everything until we
|
|
|
|
|
// find an unescaped $, at which point we break out.
|
|
|
|
|
if (scanning_math) {
|
|
|
|
|
if (escaped)
|
|
|
|
|
escaped = false;
|
|
|
|
|
else if (ch == '\\')
|
|
|
|
|
escaped = true;
|
|
|
|
|
else if (ch == '$')
|
|
|
|
|
scanning_math = false;
|
|
|
|
|
ret += ch;
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we're scanning a command name, then we just
|
|
|
|
|
// discard characters until we hit something that
|
|
|
|
|
// isn't alpha.
|
|
|
|
|
if (scanning_cmd) {
|
|
|
|
|
if (isAlphaASCII(ch)) {
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
escaped = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// so we're done with this command.
|
|
|
|
|
// now we fall through and check this character.
|
|
|
|
|
scanning_cmd = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// was the last character a \? If so, then this is something like: \\,
|
|
|
|
|
// or \$, so we'll just output it. That's probably not always right...
|
|
|
|
|
if (escaped) {
|
|
|
|
|
ret += ch;
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
escaped = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ch == '$') {
|
|
|
|
|
ret += ch;
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
scanning_math = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we just ignore braces
|
|
|
|
|
if (ch == '{' || ch == '}') {
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we're going to check things that look like commands, so if
|
|
|
|
|
// this doesn't, just output it.
|
|
|
|
|
if (ch != '\\') {
|
|
|
|
|
ret += ch;
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ok, could be a command of some sort
|
|
|
|
|
// let's see if it corresponds to some unicode
|
|
|
|
|
// unicodesymbols has things in the form: \"{u},
|
|
|
|
|
// whereas we may see things like: \"u. So we'll
|
|
|
|
|
// look for that and change it, if necessary.
|
|
|
|
|
static boost::regex const reg("^\\\\\\W\\w");
|
|
|
|
|
if (boost::regex_search(to_utf8(val), reg)) {
|
|
|
|
|
val.insert(3, from_ascii("}"));
|
|
|
|
|
val.insert(2, from_ascii("{"));
|
|
|
|
|
}
|
|
|
|
|
docstring rem;
|
|
|
|
|
docstring const cnvtd = Encodings::fromLaTeXCommand(val, rem);
|
|
|
|
|
if (!cnvtd.empty()) {
|
|
|
|
|
// it did, so we'll take that bit and proceed with what's left
|
|
|
|
|
ret += cnvtd;
|
|
|
|
|
val = rem;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// it's a command of some sort
|
|
|
|
|
scanning_cmd = true;
|
|
|
|
|
escaped = true;
|
|
|
|
|
val = val.substr(1);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // anon namespace
|
|
|
|
|
|
|
|
|
|
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BibTeXInfo
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
|
|
|
|
|
: is_bibtex_(true), bib_key_(key), entry_type_(type), info_()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool BibTeXInfo::hasField(docstring const & field) const
|
|
|
|
|
{
|
|
|
|
|
return count(field) == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const BibTeXInfo::getAbbreviatedAuthor() const
|
|
|
|
|
{
|
|
|
|
|
if (!is_bibtex_) {
|
|
|
|
|
docstring const opt = trim(operator[]("label"));
|
|
|
|
|
if (opt.empty())
|
|
|
|
|
return docstring();
|
|
|
|
|
|
|
|
|
|
docstring authors;
|
|
|
|
|
split(opt, authors, '(');
|
|
|
|
|
return authors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
docstring author = operator[]("author");
|
|
|
|
|
if (author.empty()) {
|
|
|
|
|
author = operator[]("editor");
|
|
|
|
|
if (author.empty())
|
|
|
|
|
return bib_key_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OK, we've got some names. Let's format them.
|
|
|
|
|
// Try to split the author list on " and "
|
|
|
|
|
vector<docstring> const authors =
|
|
|
|
|
getVectorFromString(author, from_ascii(" and "));
|
|
|
|
|
|
|
|
|
|
if (authors.size() == 2)
|
|
|
|
|
return bformat(_("%1$s and %2$s"),
|
|
|
|
|
familyName(authors[0]), familyName(authors[1]));
|
|
|
|
|
|
|
|
|
|
if (authors.size() > 2)
|
|
|
|
|
return bformat(_("%1$s et al."), familyName(authors[0]));
|
|
|
|
|
|
|
|
|
|
return familyName(authors[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const BibTeXInfo::getYear() const
|
|
|
|
|
{
|
|
|
|
|
if (is_bibtex_)
|
|
|
|
|
return operator[]("year");
|
|
|
|
|
|
|
|
|
|
docstring const opt = trim(operator[]("label"));
|
|
|
|
|
if (opt.empty())
|
|
|
|
|
return docstring();
|
|
|
|
|
|
|
|
|
|
docstring authors;
|
|
|
|
|
docstring const tmp = split(opt, authors, '(');
|
|
|
|
|
docstring year;
|
|
|
|
|
split(tmp, year, ')');
|
|
|
|
|
return year;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const BibTeXInfo::getXRef() const
|
|
|
|
|
{
|
|
|
|
|
if (!is_bibtex_)
|
|
|
|
|
return docstring();
|
|
|
|
|
return operator[]("crossref");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const & BibTeXInfo::getInfo(BibTeXInfo const * const xref) const
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2009-01-17 15:55:32 +00:00
|
|
|
|
if (!info_.empty())
|
|
|
|
|
return info_;
|
|
|
|
|
|
2008-02-14 17:00:40 +00:00
|
|
|
|
if (!is_bibtex_) {
|
2007-08-20 16:30:02 +00:00
|
|
|
|
BibTeXInfo::const_iterator it = find(from_ascii("ref"));
|
2009-01-17 15:55:32 +00:00
|
|
|
|
info_ = it->second;
|
|
|
|
|
return info_;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
2007-08-16 01:59:20 +00:00
|
|
|
|
|
2007-11-05 20:33:20 +00:00
|
|
|
|
// FIXME
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
// This could be made a lot better using the entry_type_
|
2007-11-05 20:33:20 +00:00
|
|
|
|
// field to customize the output based upon entry type.
|
2007-08-16 01:59:20 +00:00
|
|
|
|
|
2007-11-05 20:33:20 +00:00
|
|
|
|
// Search for all possible "required" fields
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
docstring author = getValueForKey("author", xref);
|
2007-08-14 16:50:51 +00:00
|
|
|
|
if (author.empty())
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
author = getValueForKey("editor", xref);
|
2007-08-16 01:59:20 +00:00
|
|
|
|
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
docstring year = getValueForKey("year", xref);
|
|
|
|
|
docstring title = getValueForKey("title", xref);
|
|
|
|
|
docstring docLoc = getValueForKey("pages", xref);
|
2007-08-16 01:59:20 +00:00
|
|
|
|
if (docLoc.empty()) {
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
docLoc = getValueForKey("chapter", xref);
|
2007-08-16 01:59:20 +00:00
|
|
|
|
if (!docLoc.empty())
|
2009-01-17 18:13:22 +00:00
|
|
|
|
docLoc = _("Ch. ") + docLoc;
|
2007-11-05 20:33:20 +00:00
|
|
|
|
} else {
|
2009-01-17 18:13:22 +00:00
|
|
|
|
docLoc = _("pp. ") + docLoc;
|
2007-11-05 20:33:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
docstring media = getValueForKey("journal", xref);
|
2007-11-05 20:33:20 +00:00
|
|
|
|
if (media.empty()) {
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
media = getValueForKey("publisher", xref);
|
2007-08-16 01:59:20 +00:00
|
|
|
|
if (media.empty()) {
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
media = getValueForKey("school", xref);
|
2007-11-05 20:33:20 +00:00
|
|
|
|
if (media.empty())
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
media = getValueForKey("institution");
|
2007-08-16 01:59:20 +00:00
|
|
|
|
}
|
2007-11-05 20:33:20 +00:00
|
|
|
|
}
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
docstring volume = getValueForKey("volume", xref);
|
2007-11-05 20:33:20 +00:00
|
|
|
|
|
|
|
|
|
odocstringstream result;
|
|
|
|
|
if (!author.empty())
|
|
|
|
|
result << author << ", ";
|
|
|
|
|
if (!title.empty())
|
|
|
|
|
result << title;
|
|
|
|
|
if (!media.empty())
|
|
|
|
|
result << ", " << media;
|
|
|
|
|
if (!year.empty())
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
result << " (" << year << ")";
|
2007-11-05 20:33:20 +00:00
|
|
|
|
if (!docLoc.empty())
|
|
|
|
|
result << ", " << docLoc;
|
|
|
|
|
|
|
|
|
|
docstring const result_str = rtrim(result.str());
|
2009-01-17 15:55:32 +00:00
|
|
|
|
if (!result_str.empty()) {
|
|
|
|
|
info_ = convertLaTeXCommands(result_str);
|
|
|
|
|
return info_;
|
|
|
|
|
}
|
2007-11-05 20:33:20 +00:00
|
|
|
|
|
|
|
|
|
// This should never happen (or at least be very unusual!)
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
static docstring e = docstring();
|
|
|
|
|
return e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const & BibTeXInfo::operator[](docstring const & field) const
|
|
|
|
|
{
|
|
|
|
|
BibTeXInfo::const_iterator it = find(field);
|
|
|
|
|
if (it != end())
|
|
|
|
|
return it->second;
|
|
|
|
|
static docstring const empty_value = docstring();
|
|
|
|
|
return empty_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const & BibTeXInfo::operator[](string const & field) const
|
|
|
|
|
{
|
|
|
|
|
return operator[](from_ascii(field));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring BibTeXInfo::getValueForKey(string const & key,
|
|
|
|
|
BibTeXInfo const * const xref) const
|
|
|
|
|
{
|
|
|
|
|
docstring const ret = operator[](key);
|
2009-04-18 15:43:19 +00:00
|
|
|
|
if (!ret.empty() || !xref)
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
return ret;
|
|
|
|
|
return (*xref)[key];
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-05 20:33:20 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2007-08-20 16:30:02 +00:00
|
|
|
|
//
|
|
|
|
|
// BiblioInfo
|
|
|
|
|
//
|
2007-11-05 20:33:20 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2007-08-20 16:30:02 +00:00
|
|
|
|
|
2007-08-14 16:50:51 +00:00
|
|
|
|
namespace {
|
2007-12-12 19:28:07 +00:00
|
|
|
|
// A functor for use with sort, leading to case insensitive sorting
|
|
|
|
|
class compareNoCase: public binary_function<docstring, docstring, bool>
|
2007-08-20 16:30:02 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool operator()(docstring const & s1, docstring const & s2) const {
|
|
|
|
|
return compare_no_case(s1, s2) < 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
2007-08-20 16:30:02 +00:00
|
|
|
|
vector<docstring> const BiblioInfo::getKeys() const
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2007-08-20 16:30:02 +00:00
|
|
|
|
vector<docstring> bibkeys;
|
|
|
|
|
BiblioInfo::const_iterator it = begin();
|
|
|
|
|
for (; it != end(); ++it)
|
|
|
|
|
bibkeys.push_back(it->first);
|
2007-12-12 19:28:07 +00:00
|
|
|
|
sort(bibkeys.begin(), bibkeys.end(), compareNoCase());
|
2007-08-20 16:30:02 +00:00
|
|
|
|
return bibkeys;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-20 16:30:02 +00:00
|
|
|
|
vector<docstring> const BiblioInfo::getFields() const
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2007-08-20 16:30:02 +00:00
|
|
|
|
vector<docstring> bibfields;
|
2008-02-14 17:00:40 +00:00
|
|
|
|
set<docstring>::const_iterator it = field_names_.begin();
|
|
|
|
|
set<docstring>::const_iterator end = field_names_.end();
|
2007-08-20 16:30:02 +00:00
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
bibfields.push_back(*it);
|
2007-12-12 19:28:07 +00:00
|
|
|
|
sort(bibfields.begin(), bibfields.end());
|
2007-08-20 16:30:02 +00:00
|
|
|
|
return bibfields;
|
|
|
|
|
}
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
2007-08-20 16:30:02 +00:00
|
|
|
|
|
|
|
|
|
vector<docstring> const BiblioInfo::getEntries() const
|
|
|
|
|
{
|
|
|
|
|
vector<docstring> bibentries;
|
2008-02-14 17:00:40 +00:00
|
|
|
|
set<docstring>::const_iterator it = entry_types_.begin();
|
|
|
|
|
set<docstring>::const_iterator end = entry_types_.end();
|
2007-08-20 16:30:02 +00:00
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
bibentries.push_back(*it);
|
2007-12-12 19:28:07 +00:00
|
|
|
|
sort(bibentries.begin(), bibentries.end());
|
2007-08-20 16:30:02 +00:00
|
|
|
|
return bibentries;
|
|
|
|
|
}
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
|
2007-08-20 16:30:02 +00:00
|
|
|
|
docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key) const
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2007-08-20 16:30:02 +00:00
|
|
|
|
BiblioInfo::const_iterator it = find(key);
|
|
|
|
|
if (it == end())
|
|
|
|
|
return docstring();
|
|
|
|
|
BibTeXInfo const & data = it->second;
|
|
|
|
|
return data.getAbbreviatedAuthor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const BiblioInfo::getYear(docstring const & key) const
|
|
|
|
|
{
|
|
|
|
|
BiblioInfo::const_iterator it = find(key);
|
|
|
|
|
if (it == end())
|
|
|
|
|
return docstring();
|
|
|
|
|
BibTeXInfo const & data = it->second;
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
docstring year = data.getYear();
|
|
|
|
|
if (!year.empty())
|
|
|
|
|
return year;
|
|
|
|
|
// let's try the crossref
|
|
|
|
|
docstring const xref = data.getXRef();
|
|
|
|
|
if (xref.empty())
|
|
|
|
|
return _("No year"); // no luck
|
|
|
|
|
BiblioInfo::const_iterator const xrefit = find(xref);
|
|
|
|
|
if (xrefit == end())
|
|
|
|
|
return _("No year"); // no luck again
|
|
|
|
|
BibTeXInfo const & xref_data = xrefit->second;
|
|
|
|
|
return xref_data.getYear();
|
2007-08-20 16:30:02 +00:00
|
|
|
|
return data.getYear();
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-20 16:30:02 +00:00
|
|
|
|
docstring const BiblioInfo::getInfo(docstring const & key) const
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2007-08-20 16:30:02 +00:00
|
|
|
|
BiblioInfo::const_iterator it = find(key);
|
|
|
|
|
if (it == end())
|
2007-08-14 16:50:51 +00:00
|
|
|
|
return docstring();
|
2007-08-20 16:30:02 +00:00
|
|
|
|
BibTeXInfo const & data = it->second;
|
Backport r27635, r28193, r28194, r28220, r29094, and r29095. The point
of these, taken together, is to improve the display of information in
InsetCitation and GuiCitation, by gathering missing data from the
crossref, if one is defined, basically as BibTeX does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-18 15:29:36 +00:00
|
|
|
|
BibTeXInfo const * xrefptr = 0;
|
|
|
|
|
docstring const xref = data.getXRef();
|
|
|
|
|
if (!xref.empty()) {
|
|
|
|
|
BiblioInfo::const_iterator const xrefit = find(xref);
|
|
|
|
|
if (xrefit != end())
|
|
|
|
|
xrefptr = &(xrefit->second);
|
|
|
|
|
}
|
|
|
|
|
return data.getInfo(xrefptr);
|
2007-08-20 16:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector<docstring> const BiblioInfo::getCiteStrings(
|
|
|
|
|
docstring const & key, Buffer const & buf) const
|
|
|
|
|
{
|
2008-04-20 15:00:11 +00:00
|
|
|
|
CiteEngine const engine = buf.params().citeEngine();
|
|
|
|
|
if (engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL)
|
2007-08-20 16:30:02 +00:00
|
|
|
|
return getNumericalStrings(key, buf);
|
|
|
|
|
else
|
|
|
|
|
return getAuthorYearStrings(key, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector<docstring> const BiblioInfo::getNumericalStrings(
|
|
|
|
|
docstring const & key, Buffer const & buf) const
|
|
|
|
|
{
|
|
|
|
|
if (empty())
|
|
|
|
|
return vector<docstring>();
|
|
|
|
|
|
|
|
|
|
docstring const author = getAbbreviatedAuthor(key);
|
|
|
|
|
docstring const year = getYear(key);
|
|
|
|
|
if (author.empty() || year.empty())
|
|
|
|
|
return vector<docstring>();
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine());
|
2007-08-20 16:30:02 +00:00
|
|
|
|
|
|
|
|
|
vector<docstring> vec(styles.size());
|
2008-04-20 15:00:11 +00:00
|
|
|
|
for (size_t i = 0; i != vec.size(); ++i) {
|
2007-08-20 16:30:02 +00:00
|
|
|
|
docstring str;
|
|
|
|
|
|
|
|
|
|
switch (styles[i]) {
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITE:
|
|
|
|
|
case CITEP:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = from_ascii("[#ID]");
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case NOCITE:
|
2007-12-20 15:46:14 +00:00
|
|
|
|
str = _("Add to bibliography only.");
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITET:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author + " [#ID]";
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEALT:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author + " #ID";
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEALP:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = from_ascii("#ID");
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEAUTHOR:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEYEAR:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = year;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEYEARPAR:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = '(' + year + ')';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec[i] = str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector<docstring> const BiblioInfo::getAuthorYearStrings(
|
|
|
|
|
docstring const & key, Buffer const & buf) const
|
|
|
|
|
{
|
|
|
|
|
if (empty())
|
|
|
|
|
return vector<docstring>();
|
|
|
|
|
|
|
|
|
|
docstring const author = getAbbreviatedAuthor(key);
|
|
|
|
|
docstring const year = getYear(key);
|
|
|
|
|
if (author.empty() || year.empty())
|
|
|
|
|
return vector<docstring>();
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine());
|
2007-08-20 16:30:02 +00:00
|
|
|
|
|
|
|
|
|
vector<docstring> vec(styles.size());
|
2008-04-20 15:00:11 +00:00
|
|
|
|
for (size_t i = 0; i != vec.size(); ++i) {
|
2007-08-20 16:30:02 +00:00
|
|
|
|
docstring str;
|
|
|
|
|
|
|
|
|
|
switch (styles[i]) {
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITE:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
// jurabib only: Author/Annotator
|
|
|
|
|
// (i.e. the "before" field, 2nd opt arg)
|
|
|
|
|
str = author + "/<" + _("before") + '>';
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case NOCITE:
|
2007-12-20 15:46:14 +00:00
|
|
|
|
str = _("Add to bibliography only.");
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITET:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author + " (" + year + ')';
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEP:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = '(' + author + ", " + year + ')';
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEALT:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author + ' ' + year ;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEALP:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author + ", " + year ;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEAUTHOR:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = author;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEYEAR:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = year;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
case CITEYEARPAR:
|
2007-08-20 16:30:02 +00:00
|
|
|
|
str = '(' + year + ')';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
vec[i] = str;
|
|
|
|
|
}
|
|
|
|
|
return vec;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 16:30:02 +00:00
|
|
|
|
|
2008-04-25 20:03:03 +00:00
|
|
|
|
void BiblioInfo::mergeBiblioInfo(BiblioInfo const & info)
|
|
|
|
|
{
|
|
|
|
|
bimap_.insert(info.begin(), info.end());
|
2007-08-20 16:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-05 20:33:20 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2007-08-20 16:30:02 +00:00
|
|
|
|
//
|
|
|
|
|
// CitationStyle
|
|
|
|
|
//
|
2007-11-05 20:33:20 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2007-08-20 16:30:02 +00:00
|
|
|
|
|
2007-08-14 16:50:51 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char const * const citeCommands[] = {
|
2008-10-25 13:26:30 +00:00
|
|
|
|
"cite", "citet", "citep", "citealt", "citealp",
|
|
|
|
|
"citeauthor", "citeyear", "citeyearpar", "nocite" };
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
unsigned int const nCiteCommands =
|
|
|
|
|
sizeof(citeCommands) / sizeof(char *);
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
CiteStyle const citeStylesArray[] = {
|
2008-09-25 18:13:25 +00:00
|
|
|
|
CITE, CITET, CITEP, CITEALT, CITEALP,
|
|
|
|
|
CITEAUTHOR, CITEYEAR, CITEYEARPAR, NOCITE };
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
unsigned int const nCiteStyles =
|
2008-04-20 15:00:11 +00:00
|
|
|
|
sizeof(citeStylesArray) / sizeof(CiteStyle);
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
CiteStyle const citeStylesFull[] = {
|
|
|
|
|
CITET, CITEP, CITEALT, CITEALP, CITEAUTHOR };
|
|
|
|
|
|
|
|
|
|
unsigned int const nCiteStylesFull =
|
|
|
|
|
sizeof(citeStylesFull) / sizeof(CiteStyle);
|
|
|
|
|
|
|
|
|
|
CiteStyle const citeStylesUCase[] = {
|
|
|
|
|
CITET, CITEP, CITEALT, CITEALP, CITEAUTHOR };
|
|
|
|
|
|
|
|
|
|
unsigned int const nCiteStylesUCase =
|
|
|
|
|
sizeof(citeStylesUCase) / sizeof(CiteStyle);
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
CitationStyle citationStyleFromString(string const & command)
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2008-04-20 15:00:11 +00:00
|
|
|
|
CitationStyle s;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
if (command.empty())
|
2008-04-20 15:00:11 +00:00
|
|
|
|
return s;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
string cmd = command;
|
|
|
|
|
if (cmd[0] == 'C') {
|
2008-04-20 15:00:11 +00:00
|
|
|
|
s.forceUpperCase = true;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
cmd[0] = 'c';
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
size_t const n = cmd.size() - 1;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
if (cmd != "cite" && cmd[n] == '*') {
|
2008-04-20 15:00:11 +00:00
|
|
|
|
s.full = true;
|
2008-09-08 01:18:33 +00:00
|
|
|
|
cmd = cmd.substr(0, n);
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char const * const * const last = citeCommands + nCiteCommands;
|
2007-12-12 19:28:07 +00:00
|
|
|
|
char const * const * const ptr = find(citeCommands, last, cmd);
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
if (ptr != last) {
|
|
|
|
|
size_t idx = ptr - citeCommands;
|
2008-04-20 15:00:11 +00:00
|
|
|
|
s.style = citeStylesArray[idx];
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
2008-04-20 15:00:11 +00:00
|
|
|
|
return s;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
string citationStyleToString(const CitationStyle & s)
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
2008-04-20 15:00:11 +00:00
|
|
|
|
string cite = citeCommands[s.style];
|
|
|
|
|
if (s.full) {
|
2007-08-14 16:50:51 +00:00
|
|
|
|
CiteStyle const * last = citeStylesFull + nCiteStylesFull;
|
2008-04-20 15:00:11 +00:00
|
|
|
|
if (find(citeStylesFull, last, s.style) != last)
|
2007-08-14 16:50:51 +00:00
|
|
|
|
cite += '*';
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
if (s.forceUpperCase) {
|
2007-08-14 16:50:51 +00:00
|
|
|
|
CiteStyle const * last = citeStylesUCase + nCiteStylesUCase;
|
2008-04-20 15:00:11 +00:00
|
|
|
|
if (find(citeStylesUCase, last, s.style) != last)
|
2007-08-14 16:50:51 +00:00
|
|
|
|
cite[0] = 'C';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cite;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
vector<CiteStyle> citeStyles(CiteEngine engine)
|
2007-08-14 16:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int nStyles = 0;
|
|
|
|
|
unsigned int start = 0;
|
|
|
|
|
|
|
|
|
|
switch (engine) {
|
|
|
|
|
case ENGINE_BASIC:
|
2007-12-20 15:46:14 +00:00
|
|
|
|
nStyles = 2;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
start = 0;
|
|
|
|
|
break;
|
|
|
|
|
case ENGINE_NATBIB_AUTHORYEAR:
|
|
|
|
|
case ENGINE_NATBIB_NUMERICAL:
|
|
|
|
|
nStyles = nCiteStyles - 1;
|
|
|
|
|
start = 1;
|
|
|
|
|
break;
|
|
|
|
|
case ENGINE_JURABIB:
|
|
|
|
|
nStyles = nCiteStyles;
|
|
|
|
|
start = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 15:00:11 +00:00
|
|
|
|
vector<CiteStyle> styles(nStyles);
|
2007-11-05 20:33:20 +00:00
|
|
|
|
size_t i = 0;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
int j = start;
|
|
|
|
|
for (; i != styles.size(); ++i, ++j)
|
2008-04-20 15:00:11 +00:00
|
|
|
|
styles[i] = citeStylesArray[j];
|
2007-08-14 16:50:51 +00:00
|
|
|
|
|
|
|
|
|
return styles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|