mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
move citation enums into header of their own
remove biblio:: namespace git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24385 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4d88adcde5
commit
b35b731fbf
@ -34,8 +34,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
namespace lyx {
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -287,9 +287,8 @@ docstring const BiblioInfo::getInfo(docstring const & key) const
|
|||||||
vector<docstring> const BiblioInfo::getCiteStrings(
|
vector<docstring> const BiblioInfo::getCiteStrings(
|
||||||
docstring const & key, Buffer const & buf) const
|
docstring const & key, Buffer const & buf) const
|
||||||
{
|
{
|
||||||
biblio::CiteEngine const engine = buf.params().citeEngine();
|
CiteEngine const engine = buf.params().citeEngine();
|
||||||
if (engine == biblio::ENGINE_BASIC ||
|
if (engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL)
|
||||||
engine == biblio::ENGINE_NATBIB_NUMERICAL)
|
|
||||||
return getNumericalStrings(key, buf);
|
return getNumericalStrings(key, buf);
|
||||||
else
|
else
|
||||||
return getAuthorYearStrings(key, buf);
|
return getAuthorYearStrings(key, buf);
|
||||||
@ -307,44 +306,43 @@ vector<docstring> const BiblioInfo::getNumericalStrings(
|
|||||||
if (author.empty() || year.empty())
|
if (author.empty() || year.empty())
|
||||||
return vector<docstring>();
|
return vector<docstring>();
|
||||||
|
|
||||||
vector<biblio::CiteStyle> const & styles =
|
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine());
|
||||||
biblio::getCiteStyles(buf.params().citeEngine());
|
|
||||||
|
|
||||||
vector<docstring> vec(styles.size());
|
vector<docstring> vec(styles.size());
|
||||||
for (vector<docstring>::size_type i = 0; i != vec.size(); ++i) {
|
for (size_t i = 0; i != vec.size(); ++i) {
|
||||||
docstring str;
|
docstring str;
|
||||||
|
|
||||||
switch (styles[i]) {
|
switch (styles[i]) {
|
||||||
case biblio::CITE:
|
case CITE:
|
||||||
case biblio::CITEP:
|
case CITEP:
|
||||||
str = from_ascii("[#ID]");
|
str = from_ascii("[#ID]");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::NOCITE:
|
case NOCITE:
|
||||||
str = _("Add to bibliography only.");
|
str = _("Add to bibliography only.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITET:
|
case CITET:
|
||||||
str = author + " [#ID]";
|
str = author + " [#ID]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEALT:
|
case CITEALT:
|
||||||
str = author + " #ID";
|
str = author + " #ID";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEALP:
|
case CITEALP:
|
||||||
str = from_ascii("#ID");
|
str = from_ascii("#ID");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEAUTHOR:
|
case CITEAUTHOR:
|
||||||
str = author;
|
str = author;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEYEAR:
|
case CITEYEAR:
|
||||||
str = year;
|
str = year;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEYEARPAR:
|
case CITEYEARPAR:
|
||||||
str = '(' + year + ')';
|
str = '(' + year + ')';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -367,49 +365,48 @@ vector<docstring> const BiblioInfo::getAuthorYearStrings(
|
|||||||
if (author.empty() || year.empty())
|
if (author.empty() || year.empty())
|
||||||
return vector<docstring>();
|
return vector<docstring>();
|
||||||
|
|
||||||
vector<biblio::CiteStyle> const & styles =
|
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine());
|
||||||
getCiteStyles(buf.params().citeEngine());
|
|
||||||
|
|
||||||
vector<docstring> vec(styles.size());
|
vector<docstring> vec(styles.size());
|
||||||
for (vector<docstring>::size_type i = 0; i != vec.size(); ++i) {
|
for (size_t i = 0; i != vec.size(); ++i) {
|
||||||
docstring str;
|
docstring str;
|
||||||
|
|
||||||
switch (styles[i]) {
|
switch (styles[i]) {
|
||||||
case biblio::CITE:
|
case CITE:
|
||||||
// jurabib only: Author/Annotator
|
// jurabib only: Author/Annotator
|
||||||
// (i.e. the "before" field, 2nd opt arg)
|
// (i.e. the "before" field, 2nd opt arg)
|
||||||
str = author + "/<" + _("before") + '>';
|
str = author + "/<" + _("before") + '>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::NOCITE:
|
case NOCITE:
|
||||||
str = _("Add to bibliography only.");
|
str = _("Add to bibliography only.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITET:
|
case CITET:
|
||||||
str = author + " (" + year + ')';
|
str = author + " (" + year + ')';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEP:
|
case CITEP:
|
||||||
str = '(' + author + ", " + year + ')';
|
str = '(' + author + ", " + year + ')';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEALT:
|
case CITEALT:
|
||||||
str = author + ' ' + year ;
|
str = author + ' ' + year ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEALP:
|
case CITEALP:
|
||||||
str = author + ", " + year ;
|
str = author + ", " + year ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEAUTHOR:
|
case CITEAUTHOR:
|
||||||
str = author;
|
str = author;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEYEAR:
|
case CITEYEAR:
|
||||||
str = year;
|
str = year;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::CITEYEARPAR:
|
case CITEYEARPAR:
|
||||||
str = '(' + year + ')';
|
str = '(' + year + ')';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -424,7 +421,7 @@ void BiblioInfo::fillWithBibKeys(Buffer const * const buf)
|
|||||||
/// if this is a child document and the parent is already loaded
|
/// if this is a child document and the parent is already loaded
|
||||||
/// use the parent's list instead [ale990412]
|
/// use the parent's list instead [ale990412]
|
||||||
Buffer const * const tmp = buf->masterBuffer();
|
Buffer const * const tmp = buf->masterBuffer();
|
||||||
LASSERT(tmp, /**/);
|
LASSERT(tmp, return);
|
||||||
if (tmp != buf) {
|
if (tmp != buf) {
|
||||||
this->fillWithBibKeys(tmp);
|
this->fillWithBibKeys(tmp);
|
||||||
return;
|
return;
|
||||||
@ -435,8 +432,6 @@ void BiblioInfo::fillWithBibKeys(Buffer const * const buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace biblio {
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// CitationStyle
|
// CitationStyle
|
||||||
@ -453,12 +448,12 @@ char const * const citeCommands[] = {
|
|||||||
unsigned int const nCiteCommands =
|
unsigned int const nCiteCommands =
|
||||||
sizeof(citeCommands) / sizeof(char *);
|
sizeof(citeCommands) / sizeof(char *);
|
||||||
|
|
||||||
CiteStyle const citeStyles[] = {
|
CiteStyle const citeStylesArray[] = {
|
||||||
CITE, NOCITE, CITET, CITEP, CITEALT,
|
CITE, NOCITE, CITET, CITEP, CITEALT,
|
||||||
CITEALP, CITEAUTHOR, CITEYEAR, CITEYEARPAR };
|
CITEALP, CITEAUTHOR, CITEYEAR, CITEYEARPAR };
|
||||||
|
|
||||||
unsigned int const nCiteStyles =
|
unsigned int const nCiteStyles =
|
||||||
sizeof(citeStyles) / sizeof(CiteStyle);
|
sizeof(citeStylesArray) / sizeof(CiteStyle);
|
||||||
|
|
||||||
CiteStyle const citeStylesFull[] = {
|
CiteStyle const citeStylesFull[] = {
|
||||||
CITET, CITEP, CITEALT, CITEALP, CITEAUTHOR };
|
CITET, CITEP, CITEALT, CITEALP, CITEAUTHOR };
|
||||||
@ -475,21 +470,21 @@ unsigned int const nCiteStylesUCase =
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
CitationStyle::CitationStyle(string const & command)
|
CitationStyle citationStyleFromString(string const & command)
|
||||||
: style(CITE), full(false), forceUCase(false)
|
|
||||||
{
|
{
|
||||||
|
CitationStyle s;
|
||||||
if (command.empty())
|
if (command.empty())
|
||||||
return;
|
return s;
|
||||||
|
|
||||||
string cmd = command;
|
string cmd = command;
|
||||||
if (cmd[0] == 'C') {
|
if (cmd[0] == 'C') {
|
||||||
forceUCase = true;
|
s.forceUpperCase = true;
|
||||||
cmd[0] = 'c';
|
cmd[0] = 'c';
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type const n = cmd.size() - 1;
|
size_t const n = cmd.size() - 1;
|
||||||
if (cmd != "cite" && cmd[n] == '*') {
|
if (cmd != "cite" && cmd[n] == '*') {
|
||||||
full = true;
|
s.full = true;
|
||||||
cmd = cmd.substr(0,n);
|
cmd = cmd.substr(0,n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,31 +493,31 @@ CitationStyle::CitationStyle(string const & command)
|
|||||||
|
|
||||||
if (ptr != last) {
|
if (ptr != last) {
|
||||||
size_t idx = ptr - citeCommands;
|
size_t idx = ptr - citeCommands;
|
||||||
style = citeStyles[idx];
|
s.style = citeStylesArray[idx];
|
||||||
}
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const CitationStyle::asLatexStr() const
|
string citationStyleToString(const CitationStyle & s)
|
||||||
{
|
{
|
||||||
string cite = citeCommands[style];
|
string cite = citeCommands[s.style];
|
||||||
if (full) {
|
if (s.full) {
|
||||||
CiteStyle const * last = citeStylesFull + nCiteStylesFull;
|
CiteStyle const * last = citeStylesFull + nCiteStylesFull;
|
||||||
if (find(citeStylesFull, last, style) != last)
|
if (find(citeStylesFull, last, s.style) != last)
|
||||||
cite += '*';
|
cite += '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceUCase) {
|
if (s.forceUpperCase) {
|
||||||
CiteStyle const * last = citeStylesUCase + nCiteStylesUCase;
|
CiteStyle const * last = citeStylesUCase + nCiteStylesUCase;
|
||||||
if (find(citeStylesUCase, last, style) != last)
|
if (find(citeStylesUCase, last, s.style) != last)
|
||||||
cite[0] = 'C';
|
cite[0] = 'C';
|
||||||
}
|
}
|
||||||
|
|
||||||
return cite;
|
return cite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<CiteStyle> citeStyles(CiteEngine engine)
|
||||||
vector<CiteStyle> const getCiteStyles(CiteEngine const engine)
|
|
||||||
{
|
{
|
||||||
unsigned int nStyles = 0;
|
unsigned int nStyles = 0;
|
||||||
unsigned int start = 0;
|
unsigned int start = 0;
|
||||||
@ -543,17 +538,14 @@ vector<CiteStyle> const getCiteStyles(CiteEngine const engine)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef vector<CiteStyle> cite_vec;
|
vector<CiteStyle> styles(nStyles);
|
||||||
|
|
||||||
cite_vec styles(nStyles);
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
int j = start;
|
int j = start;
|
||||||
for (; i != styles.size(); ++i, ++j)
|
for (; i != styles.size(); ++i, ++j)
|
||||||
styles[i] = citeStyles[j];
|
styles[i] = citeStylesArray[j];
|
||||||
|
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace biblio
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BIBLIO_H
|
#ifndef BIBLIOINFO_H
|
||||||
#define BIBLIO_H
|
#define BIBLIOINFO_H
|
||||||
|
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
|
#include "Citation.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -25,49 +27,14 @@ namespace lyx {
|
|||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
|
|
||||||
namespace biblio {
|
/// FIXME: To Citation.cpp?
|
||||||
|
|
||||||
enum CiteEngine {
|
|
||||||
ENGINE_BASIC,
|
|
||||||
ENGINE_NATBIB_AUTHORYEAR,
|
|
||||||
ENGINE_NATBIB_NUMERICAL,
|
|
||||||
ENGINE_JURABIB
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CiteStyle {
|
|
||||||
CITE,
|
|
||||||
NOCITE,
|
|
||||||
CITET,
|
|
||||||
CITEP,
|
|
||||||
CITEALT,
|
|
||||||
CITEALP,
|
|
||||||
CITEAUTHOR,
|
|
||||||
CITEYEAR,
|
|
||||||
CITEYEARPAR
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CitationStyle {
|
|
||||||
public:
|
|
||||||
///
|
|
||||||
CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
|
|
||||||
: style(s), full(f), forceUCase(force) {}
|
|
||||||
/// \param latex_str a LaTeX command, "cite", "Citep*", etc
|
|
||||||
CitationStyle(std::string const & latex_str);
|
|
||||||
///
|
|
||||||
std::string const asLatexStr() const;
|
|
||||||
///
|
|
||||||
CiteStyle style;
|
|
||||||
///
|
|
||||||
bool full;
|
|
||||||
///
|
|
||||||
bool forceUCase;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Returns a vector of available Citation styles.
|
/// Returns a vector of available Citation styles.
|
||||||
std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
|
std::vector<CiteStyle> citeStyles(CiteEngine);
|
||||||
|
/// \param latex_str a LaTeX command, "cite", "Citep*", etc
|
||||||
|
CitationStyle citationStyleFromString(std::string const & latex_str);
|
||||||
|
/// the other way rounf
|
||||||
|
std::string citationStyleToString(CitationStyle const &);
|
||||||
|
|
||||||
} // namespace biblio
|
|
||||||
|
|
||||||
/// Class to represent information about a BibTeX or
|
/// Class to represent information about a BibTeX or
|
||||||
/// bibliography entry.
|
/// bibliography entry.
|
||||||
@ -207,4 +174,5 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
#endif
|
|
||||||
|
#endif // BIBLIOINFO_H
|
||||||
|
@ -225,15 +225,15 @@ PackageTranslator const & packagetranslator()
|
|||||||
|
|
||||||
|
|
||||||
// Cite engine
|
// Cite engine
|
||||||
typedef Translator<string, biblio::CiteEngine> CiteEngineTranslator;
|
typedef Translator<string, CiteEngine> CiteEngineTranslator;
|
||||||
|
|
||||||
|
|
||||||
CiteEngineTranslator const init_citeenginetranslator()
|
CiteEngineTranslator const init_citeenginetranslator()
|
||||||
{
|
{
|
||||||
CiteEngineTranslator translator("basic", biblio::ENGINE_BASIC);
|
CiteEngineTranslator translator("basic", ENGINE_BASIC);
|
||||||
translator.addPair("natbib_numerical", biblio::ENGINE_NATBIB_NUMERICAL);
|
translator.addPair("natbib_numerical", ENGINE_NATBIB_NUMERICAL);
|
||||||
translator.addPair("natbib_authoryear", biblio::ENGINE_NATBIB_AUTHORYEAR);
|
translator.addPair("natbib_authoryear", ENGINE_NATBIB_AUTHORYEAR);
|
||||||
translator.addPair("jurabib", biblio::ENGINE_JURABIB);
|
translator.addPair("jurabib", ENGINE_JURABIB);
|
||||||
return translator;
|
return translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ BufferParams::BufferParams()
|
|||||||
use_geometry = false;
|
use_geometry = false;
|
||||||
use_amsmath = package_auto;
|
use_amsmath = package_auto;
|
||||||
use_esint = package_auto;
|
use_esint = package_auto;
|
||||||
cite_engine_ = biblio::ENGINE_BASIC;
|
cite_engine_ = ENGINE_BASIC;
|
||||||
use_bibtopic = false;
|
use_bibtopic = false;
|
||||||
trackChanges = false;
|
trackChanges = false;
|
||||||
outputChanges = false;
|
outputChanges = false;
|
||||||
@ -1465,9 +1465,8 @@ void BufferParams::makeDocumentClass()
|
|||||||
"probably need to reconfigure LyX.\n"), from_utf8(modName));
|
"probably need to reconfigure LyX.\n"), from_utf8(modName));
|
||||||
frontend::Alert::warning(_("Module not available"),
|
frontend::Alert::warning(_("Module not available"),
|
||||||
msg + _("Some layouts may not be available."));
|
msg + _("Some layouts may not be available."));
|
||||||
lyxerr << "BufferParams::makeDocumentClass(): Module " <<
|
LYXERR0("BufferParams::makeDocumentClass(): Module " <<
|
||||||
modName << " requested but not found in module list." <<
|
modName << " requested but not found in module list.");
|
||||||
endl;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!lm->isAvailable()) {
|
if (!lm->isAvailable()) {
|
||||||
@ -1504,12 +1503,9 @@ bool BufferParams::addLayoutModule(string const & modName)
|
|||||||
{
|
{
|
||||||
LayoutModuleList::const_iterator it = layoutModules_.begin();
|
LayoutModuleList::const_iterator it = layoutModules_.begin();
|
||||||
LayoutModuleList::const_iterator end = layoutModules_.end();
|
LayoutModuleList::const_iterator end = layoutModules_.end();
|
||||||
for (; it != end; it++) {
|
for (; it != end; it++)
|
||||||
if (*it == modName)
|
if (*it == modName)
|
||||||
break;
|
return false;
|
||||||
}
|
|
||||||
if (it != layoutModules_.end())
|
|
||||||
return false;
|
|
||||||
layoutModules_.push_back(modName);
|
layoutModules_.push_back(modName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1984,18 +1980,18 @@ Encoding const & BufferParams::encoding() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
biblio::CiteEngine BufferParams::citeEngine() const
|
CiteEngine BufferParams::citeEngine() const
|
||||||
{
|
{
|
||||||
// FIXME the class should provide the numerical/
|
// FIXME the class should provide the numerical/
|
||||||
// authoryear choice
|
// authoryear choice
|
||||||
if (documentClass().provides("natbib")
|
if (documentClass().provides("natbib")
|
||||||
&& cite_engine_ != biblio::ENGINE_NATBIB_NUMERICAL)
|
&& cite_engine_ != ENGINE_NATBIB_NUMERICAL)
|
||||||
return biblio::ENGINE_NATBIB_AUTHORYEAR;
|
return ENGINE_NATBIB_AUTHORYEAR;
|
||||||
return cite_engine_;
|
return cite_engine_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferParams::setCiteEngine(biblio::CiteEngine cite_engine)
|
void BufferParams::setCiteEngine(CiteEngine cite_engine)
|
||||||
{
|
{
|
||||||
cite_engine_ = cite_engine;
|
cite_engine_ = cite_engine;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#define BUFFERPARAMS_H
|
#define BUFFERPARAMS_H
|
||||||
|
|
||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
#include "BiblioInfo.h"
|
#include "Citation.h"
|
||||||
#include "paper.h"
|
#include "paper.h"
|
||||||
|
|
||||||
#include "insets/InsetQuotes.h"
|
#include "insets/InsetQuotes.h"
|
||||||
@ -300,9 +300,9 @@ public:
|
|||||||
int const & sfscale, int const & ttscale) const;
|
int const & sfscale, int const & ttscale) const;
|
||||||
|
|
||||||
/// get the appropriate cite engine (natbib handling)
|
/// get the appropriate cite engine (natbib handling)
|
||||||
biblio::CiteEngine citeEngine() const;
|
CiteEngine citeEngine() const;
|
||||||
///
|
///
|
||||||
void setCiteEngine(biblio::CiteEngine const);
|
void setCiteEngine(CiteEngine const);
|
||||||
|
|
||||||
/// options for pdf output
|
/// options for pdf output
|
||||||
PDFOptions & pdfoptions();
|
PDFOptions & pdfoptions();
|
||||||
@ -325,7 +325,7 @@ private:
|
|||||||
void readModules(Lexer &);
|
void readModules(Lexer &);
|
||||||
|
|
||||||
/// for use with natbib
|
/// for use with natbib
|
||||||
biblio::CiteEngine cite_engine_;
|
CiteEngine cite_engine_;
|
||||||
///
|
///
|
||||||
DocumentClass * doc_class_;
|
DocumentClass * doc_class_;
|
||||||
///
|
///
|
||||||
|
55
src/Citation.h
Normal file
55
src/Citation.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file BiblioCode.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Herbert Voß
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BIBLIOCODE_H
|
||||||
|
#define BIBLIOCODE_H
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
|
||||||
|
class Buffer;
|
||||||
|
|
||||||
|
enum CiteEngine {
|
||||||
|
ENGINE_BASIC,
|
||||||
|
ENGINE_NATBIB_AUTHORYEAR,
|
||||||
|
ENGINE_NATBIB_NUMERICAL,
|
||||||
|
ENGINE_JURABIB
|
||||||
|
};
|
||||||
|
|
||||||
|
enum CiteStyle {
|
||||||
|
CITE,
|
||||||
|
NOCITE,
|
||||||
|
CITET,
|
||||||
|
CITEP,
|
||||||
|
CITEALT,
|
||||||
|
CITEALP,
|
||||||
|
CITEAUTHOR,
|
||||||
|
CITEYEAR,
|
||||||
|
CITEYEARPAR
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CitationStyle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
CitationStyle() : style(CITE), full(false), forceUpperCase(false) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
CiteStyle style;
|
||||||
|
///
|
||||||
|
bool full;
|
||||||
|
///
|
||||||
|
bool forceUpperCase;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif
|
@ -577,7 +577,7 @@ string const LaTeXFeatures::getPackages() const
|
|||||||
// natbib.sty
|
// natbib.sty
|
||||||
if (mustProvide("natbib")) {
|
if (mustProvide("natbib")) {
|
||||||
packages << "\\usepackage[";
|
packages << "\\usepackage[";
|
||||||
if (params_.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL)
|
if (params_.citeEngine() == ENGINE_NATBIB_NUMERICAL)
|
||||||
packages << "numbers";
|
packages << "numbers";
|
||||||
else
|
else
|
||||||
packages << "authoryear";
|
packages << "authoryear";
|
||||||
@ -779,7 +779,8 @@ docstring const LaTeXFeatures::getIncludedFiles(string const & fname) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LaTeXFeatures::showStruct() const {
|
void LaTeXFeatures::showStruct() const
|
||||||
|
{
|
||||||
lyxerr << "LyX needs the following commands when LaTeXing:"
|
lyxerr << "LyX needs the following commands when LaTeXing:"
|
||||||
<< "\n***** Packages:" << getPackages()
|
<< "\n***** Packages:" << getPackages()
|
||||||
<< "\n***** Macros:" << getMacros()
|
<< "\n***** Macros:" << getMacros()
|
||||||
|
@ -178,6 +178,7 @@ HEADERFILESCORE = \
|
|||||||
BufferParams.h \
|
BufferParams.h \
|
||||||
BufferView.h \
|
BufferView.h \
|
||||||
Bullet.h \
|
Bullet.h \
|
||||||
|
Citation.h \
|
||||||
Changes.h \
|
Changes.h \
|
||||||
Chktex.h \
|
Chktex.h \
|
||||||
CmdDef.h \
|
CmdDef.h \
|
||||||
|
@ -494,19 +494,19 @@ QString GuiBibtex::styleFile() const
|
|||||||
{
|
{
|
||||||
// the different bibtex packages have (and need) their
|
// the different bibtex packages have (and need) their
|
||||||
// own "plain" stylefiles
|
// own "plain" stylefiles
|
||||||
biblio::CiteEngine const engine = buffer().params().citeEngine();
|
CiteEngine const engine = buffer().params().citeEngine();
|
||||||
QString defaultstyle;
|
QString defaultstyle;
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case biblio::ENGINE_BASIC:
|
case ENGINE_BASIC:
|
||||||
defaultstyle = "plain";
|
defaultstyle = "plain";
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
case ENGINE_NATBIB_AUTHORYEAR:
|
||||||
defaultstyle = "plainnat";
|
defaultstyle = "plainnat";
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
case ENGINE_NATBIB_NUMERICAL:
|
||||||
defaultstyle = "plainnat";
|
defaultstyle = "plainnat";
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_JURABIB:
|
case ENGINE_JURABIB:
|
||||||
defaultstyle = "jurabib";
|
defaultstyle = "jurabib";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ using namespace lyx::support;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
static vector<biblio::CiteStyle> citeStyles_;
|
static vector<CiteStyle> citeStyles_;
|
||||||
|
|
||||||
|
|
||||||
template<typename String>
|
template<typename String>
|
||||||
@ -213,18 +213,18 @@ void GuiCitation::updateDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiCitation::updateFormatting(biblio::CiteStyle currentStyle)
|
void GuiCitation::updateFormatting(CiteStyle currentStyle)
|
||||||
{
|
{
|
||||||
biblio::CiteEngine const engine = citeEngine();
|
CiteEngine const engine = citeEngine();
|
||||||
bool const natbib_engine =
|
bool const natbib_engine =
|
||||||
engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
|
engine == ENGINE_NATBIB_AUTHORYEAR ||
|
||||||
engine == biblio::ENGINE_NATBIB_NUMERICAL;
|
engine == ENGINE_NATBIB_NUMERICAL;
|
||||||
bool const basic_engine = engine == biblio::ENGINE_BASIC;
|
bool const basic_engine = engine == ENGINE_BASIC;
|
||||||
|
|
||||||
bool const haveSelection =
|
bool const haveSelection =
|
||||||
selectedLV->model()->rowCount() > 0;
|
selectedLV->model()->rowCount() > 0;
|
||||||
|
|
||||||
bool const isNocite = currentStyle == biblio::NOCITE;
|
bool const isNocite = currentStyle == NOCITE;
|
||||||
|
|
||||||
fulllistCB->setEnabled(natbib_engine && haveSelection && !isNocite);
|
fulllistCB->setEnabled(natbib_engine && haveSelection && !isNocite);
|
||||||
forceuppercaseCB->setEnabled(natbib_engine && haveSelection && !isNocite);
|
forceuppercaseCB->setEnabled(natbib_engine && haveSelection && !isNocite);
|
||||||
@ -242,10 +242,10 @@ void GuiCitation::updateStyle()
|
|||||||
string const & command = params_.getCmdName();
|
string const & command = params_.getCmdName();
|
||||||
|
|
||||||
// Find the style of the citekeys
|
// Find the style of the citekeys
|
||||||
vector<biblio::CiteStyle> const & styles = citeStyles_;
|
vector<CiteStyle> const & styles = citeStyles_;
|
||||||
biblio::CitationStyle const cs(command);
|
CitationStyle const cs = citationStyleFromString(command);
|
||||||
|
|
||||||
vector<biblio::CiteStyle>::const_iterator cit =
|
vector<CiteStyle>::const_iterator cit =
|
||||||
std::find(styles.begin(), styles.end(), cs.style);
|
std::find(styles.begin(), styles.end(), cs.style);
|
||||||
|
|
||||||
// restore the latest natbib style
|
// restore the latest natbib style
|
||||||
@ -258,7 +258,7 @@ void GuiCitation::updateStyle()
|
|||||||
int const i = int(cit - styles.begin());
|
int const i = int(cit - styles.begin());
|
||||||
citationStyleCO->setCurrentIndex(i);
|
citationStyleCO->setCurrentIndex(i);
|
||||||
fulllistCB->setChecked(cs.full);
|
fulllistCB->setChecked(cs.full);
|
||||||
forceuppercaseCB->setChecked(cs.forceUCase);
|
forceuppercaseCB->setChecked(cs.forceUpperCase);
|
||||||
} else {
|
} else {
|
||||||
fulllistCB->setChecked(false);
|
fulllistCB->setChecked(false);
|
||||||
forceuppercaseCB->setChecked(false);
|
forceuppercaseCB->setChecked(false);
|
||||||
@ -266,9 +266,9 @@ void GuiCitation::updateStyle()
|
|||||||
updateFormatting(cs.style);
|
updateFormatting(cs.style);
|
||||||
}
|
}
|
||||||
|
|
||||||
//This one needs to be called whenever citationStyleCO needs
|
// This one needs to be called whenever citationStyleCO needs
|
||||||
//to be updated---and this would be on anything that changes the
|
// to be updated---and this would be on anything that changes the
|
||||||
//selection in selectedLV, or on a general update.
|
// selection in selectedLV, or on a general update.
|
||||||
void GuiCitation::fillStyles()
|
void GuiCitation::fillStyles()
|
||||||
{
|
{
|
||||||
int const oldIndex = citationStyleCO->currentIndex();
|
int const oldIndex = citationStyleCO->currentIndex();
|
||||||
@ -412,7 +412,7 @@ void GuiCitation::on_entriesCO_currentIndexChanged(int /*index*/)
|
|||||||
void GuiCitation::on_citationStyleCO_currentIndexChanged(int index)
|
void GuiCitation::on_citationStyleCO_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < citationStyleCO->count()) {
|
if (index >= 0 && index < citationStyleCO->count()) {
|
||||||
vector<biblio::CiteStyle> const & styles = citeStyles_;
|
vector<CiteStyle> const & styles = citeStyles_;
|
||||||
updateFormatting(styles[index]);
|
updateFormatting(styles[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -451,17 +451,19 @@ void GuiCitation::apply(int const choice, bool full, bool force,
|
|||||||
if (cited_keys_.isEmpty())
|
if (cited_keys_.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vector<biblio::CiteStyle> const & styles = citeStyles_;
|
vector<CiteStyle> const & styles = citeStyles_;
|
||||||
if (styles[choice] == biblio::NOCITE) {
|
if (styles[choice] == NOCITE) {
|
||||||
full = false;
|
full = false;
|
||||||
force = false;
|
force = false;
|
||||||
before.clear();
|
before.clear();
|
||||||
after.clear();
|
after.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
string const command =
|
CitationStyle s;
|
||||||
biblio::CitationStyle(styles[choice], full, force)
|
s.style = styles[choice];
|
||||||
.asLatexStr();
|
s.full = full;
|
||||||
|
s.forceUpperCase = force;
|
||||||
|
string const command = citationStyleToString(s);
|
||||||
|
|
||||||
params_.setCmdName(command);
|
params_.setCmdName(command);
|
||||||
params_["key"] = qstring_to_ucs4(cited_keys_.join(","));
|
params_["key"] = qstring_to_ucs4(cited_keys_.join(","));
|
||||||
@ -592,9 +594,9 @@ void GuiCitation::setCitedKeys()
|
|||||||
bool GuiCitation::initialiseParams(string const & data)
|
bool GuiCitation::initialiseParams(string const & data)
|
||||||
{
|
{
|
||||||
InsetCommand::string2params("citation", data, params_);
|
InsetCommand::string2params("citation", data, params_);
|
||||||
biblio::CiteEngine const engine = buffer().params().citeEngine();
|
CiteEngine const engine = buffer().params().citeEngine();
|
||||||
bibkeysInfo_.fillWithBibKeys(&buffer());
|
bibkeysInfo_.fillWithBibKeys(&buffer());
|
||||||
citeStyles_ = biblio::getCiteStyles(engine);
|
citeStyles_ = citeStyles(engine);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +648,7 @@ void GuiCitation::filterByEntryType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
biblio::CiteEngine GuiCitation::citeEngine() const
|
CiteEngine GuiCitation::citeEngine() const
|
||||||
{
|
{
|
||||||
return buffer().params().citeEngine();
|
return buffer().params().citeEngine();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
#include "GuiDialog.h"
|
#include "GuiDialog.h"
|
||||||
#include "GuiSelectionManager.h"
|
#include "GuiSelectionManager.h"
|
||||||
#include "ui_CitationUi.h"
|
#include "ui_CitationUi.h"
|
||||||
|
|
||||||
#include "BiblioInfo.h"
|
#include "BiblioInfo.h"
|
||||||
|
#include "Citation.h"
|
||||||
|
|
||||||
#include "insets/InsetCommandParams.h"
|
#include "insets/InsetCommandParams.h"
|
||||||
|
|
||||||
@ -86,7 +88,7 @@ private:
|
|||||||
/// set the styles combo
|
/// set the styles combo
|
||||||
void updateStyle();
|
void updateStyle();
|
||||||
/// set the formatting widgets
|
/// set the formatting widgets
|
||||||
void updateFormatting(biblio::CiteStyle currentStyle);
|
void updateFormatting(CiteStyle currentStyle);
|
||||||
/// last used citation style
|
/// last used citation style
|
||||||
int style_;
|
int style_;
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ private:
|
|||||||
void filterByEntryType(
|
void filterByEntryType(
|
||||||
std::vector<docstring> & keyVector, docstring entryType);
|
std::vector<docstring> & keyVector, docstring entryType);
|
||||||
///
|
///
|
||||||
biblio::CiteEngine citeEngine() const;
|
CiteEngine citeEngine() const;
|
||||||
|
|
||||||
/// \return information for this key.
|
/// \return information for this key.
|
||||||
docstring getInfo(docstring const & key) const;
|
docstring getInfo(docstring const & key) const;
|
||||||
|
@ -1440,18 +1440,18 @@ void GuiDocument::apply(BufferParams & params)
|
|||||||
preambleModule->apply(params);
|
preambleModule->apply(params);
|
||||||
|
|
||||||
// biblio
|
// biblio
|
||||||
params.setCiteEngine(biblio::ENGINE_BASIC);
|
params.setCiteEngine(ENGINE_BASIC);
|
||||||
|
|
||||||
if (biblioModule->citeNatbibRB->isChecked()) {
|
if (biblioModule->citeNatbibRB->isChecked()) {
|
||||||
bool const use_numerical_citations =
|
bool const use_numerical_citations =
|
||||||
biblioModule->citeStyleCO->currentIndex();
|
biblioModule->citeStyleCO->currentIndex();
|
||||||
if (use_numerical_citations)
|
if (use_numerical_citations)
|
||||||
params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
|
params.setCiteEngine(ENGINE_NATBIB_NUMERICAL);
|
||||||
else
|
else
|
||||||
params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
|
params.setCiteEngine(ENGINE_NATBIB_AUTHORYEAR);
|
||||||
|
|
||||||
} else if (biblioModule->citeJurabibRB->isChecked())
|
} else if (biblioModule->citeJurabibRB->isChecked())
|
||||||
params.setCiteEngine(biblio::ENGINE_JURABIB);
|
params.setCiteEngine(ENGINE_JURABIB);
|
||||||
|
|
||||||
params.use_bibtopic =
|
params.use_bibtopic =
|
||||||
biblioModule->bibtopicCB->isChecked();
|
biblioModule->bibtopicCB->isChecked();
|
||||||
@ -1754,17 +1754,17 @@ void GuiDocument::updateParams(BufferParams const & params)
|
|||||||
|
|
||||||
// biblio
|
// biblio
|
||||||
biblioModule->citeDefaultRB->setChecked(
|
biblioModule->citeDefaultRB->setChecked(
|
||||||
params.citeEngine() == biblio::ENGINE_BASIC);
|
params.citeEngine() == ENGINE_BASIC);
|
||||||
|
|
||||||
biblioModule->citeNatbibRB->setChecked(
|
biblioModule->citeNatbibRB->setChecked(
|
||||||
params.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
|
params.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
|
||||||
params.citeEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
|
params.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
|
||||||
|
|
||||||
biblioModule->citeStyleCO->setCurrentIndex(
|
biblioModule->citeStyleCO->setCurrentIndex(
|
||||||
params.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
|
params.citeEngine() == ENGINE_NATBIB_NUMERICAL);
|
||||||
|
|
||||||
biblioModule->citeJurabibRB->setChecked(
|
biblioModule->citeJurabibRB->setChecked(
|
||||||
params.citeEngine() == biblio::ENGINE_JURABIB);
|
params.citeEngine() == ENGINE_JURABIB);
|
||||||
|
|
||||||
biblioModule->bibtopicCB->setChecked(
|
biblioModule->bibtopicCB->setChecked(
|
||||||
params.use_bibtopic);
|
params.use_bibtopic);
|
||||||
|
@ -64,20 +64,20 @@ vector<string> const & possibleCiteCommands()
|
|||||||
|
|
||||||
|
|
||||||
// FIXME See the header for the issue.
|
// FIXME See the header for the issue.
|
||||||
string defaultCiteCommand(biblio::CiteEngine engine)
|
string defaultCiteCommand(CiteEngine engine)
|
||||||
{
|
{
|
||||||
string str;
|
string str;
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case biblio::ENGINE_BASIC:
|
case ENGINE_BASIC:
|
||||||
str = "cite";
|
str = "cite";
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
case ENGINE_NATBIB_AUTHORYEAR:
|
||||||
str = "citet";
|
str = "citet";
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
case ENGINE_NATBIB_NUMERICAL:
|
||||||
str = "citep";
|
str = "citep";
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_JURABIB:
|
case ENGINE_JURABIB:
|
||||||
str = "cite";
|
str = "cite";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ string defaultCiteCommand(biblio::CiteEngine engine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string asValidLatexCommand(string const & input, biblio::CiteEngine const engine)
|
string asValidLatexCommand(string const & input, CiteEngine const engine)
|
||||||
{
|
{
|
||||||
string const default_str = defaultCiteCommand(engine);
|
string const default_str = defaultCiteCommand(engine);
|
||||||
if (!InsetCitation::isCompatibleCommand(input))
|
if (!InsetCitation::isCompatibleCommand(input))
|
||||||
@ -93,12 +93,12 @@ string asValidLatexCommand(string const & input, biblio::CiteEngine const engine
|
|||||||
|
|
||||||
string output;
|
string output;
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case biblio::ENGINE_BASIC:
|
case ENGINE_BASIC:
|
||||||
output = input;
|
output = input;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
case ENGINE_NATBIB_AUTHORYEAR:
|
||||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
case ENGINE_NATBIB_NUMERICAL:
|
||||||
if (input == "cite" || input == "citefield" ||
|
if (input == "cite" || input == "citefield" ||
|
||||||
input == "citetitle" || input == "cite*")
|
input == "citetitle" || input == "cite*")
|
||||||
output = default_str;
|
output = default_str;
|
||||||
@ -108,7 +108,7 @@ string asValidLatexCommand(string const & input, biblio::CiteEngine const engine
|
|||||||
output = input;
|
output = input;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case biblio::ENGINE_JURABIB: {
|
case ENGINE_JURABIB: {
|
||||||
// Jurabib does not support the 'uppercase' natbib style.
|
// Jurabib does not support the 'uppercase' natbib style.
|
||||||
if (input[0] == 'C')
|
if (input[0] == 'C')
|
||||||
output = string(1, 'c') + input.substr(1);
|
output = string(1, 'c') + input.substr(1);
|
||||||
@ -131,7 +131,7 @@ string asValidLatexCommand(string const & input, biblio::CiteEngine const engine
|
|||||||
docstring complexLabel(Buffer const & buffer,
|
docstring complexLabel(Buffer const & buffer,
|
||||||
string const & citeType, docstring const & keyList,
|
string const & citeType, docstring const & keyList,
|
||||||
docstring const & before, docstring const & after,
|
docstring const & before, docstring const & after,
|
||||||
biblio::CiteEngine engine)
|
CiteEngine engine)
|
||||||
{
|
{
|
||||||
// Only start the process off after the buffer is loaded from file.
|
// Only start the process off after the buffer is loaded from file.
|
||||||
if (!buffer.isFullyLoaded())
|
if (!buffer.isFullyLoaded())
|
||||||
@ -222,7 +222,7 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
// One day, these might be tunable (as they are in BibTeX).
|
// One day, these might be tunable (as they are in BibTeX).
|
||||||
char op, cp; // opening and closing parenthesis.
|
char op, cp; // opening and closing parenthesis.
|
||||||
char * sep; // punctuation mark separating citation entries.
|
char * sep; // punctuation mark separating citation entries.
|
||||||
if (engine == biblio::ENGINE_BASIC) {
|
if (engine == ENGINE_BASIC) {
|
||||||
op = '[';
|
op = '[';
|
||||||
cp = ']';
|
cp = ']';
|
||||||
sep = ",";
|
sep = ",";
|
||||||
@ -252,9 +252,9 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
// authors1/<before>; ... ;
|
// authors1/<before>; ... ;
|
||||||
// authors_last, <after>
|
// authors_last, <after>
|
||||||
if (cite_type == "cite") {
|
if (cite_type == "cite") {
|
||||||
if (engine == biblio::ENGINE_BASIC) {
|
if (engine == ENGINE_BASIC) {
|
||||||
label += *it + sep_str;
|
label += *it + sep_str;
|
||||||
} else if (engine == biblio::ENGINE_JURABIB) {
|
} else if (engine == ENGINE_JURABIB) {
|
||||||
if (it == keys.begin())
|
if (it == keys.begin())
|
||||||
label += author + before_str + sep_str;
|
label += author + before_str + sep_str;
|
||||||
else
|
else
|
||||||
@ -269,25 +269,25 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
// authors_last (<before> year, <after>)
|
// authors_last (<before> year, <after>)
|
||||||
} else if (cite_type == "citet") {
|
} else if (cite_type == "citet") {
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
case ENGINE_NATBIB_AUTHORYEAR:
|
||||||
label += author + op_str + before_str +
|
label += author + op_str + before_str +
|
||||||
year + cp + sep_str;
|
year + cp + sep_str;
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
case ENGINE_NATBIB_NUMERICAL:
|
||||||
label += author + op_str + before_str + '#' + *it + cp + sep_str;
|
label += author + op_str + before_str + '#' + *it + cp + sep_str;
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_JURABIB:
|
case ENGINE_JURABIB:
|
||||||
label += before_str + author + op_str +
|
label += before_str + author + op_str +
|
||||||
year + cp + sep_str;
|
year + cp + sep_str;
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_BASIC:
|
case ENGINE_BASIC:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// author, year; author, year; ...
|
// author, year; author, year; ...
|
||||||
} else if (cite_type == "citep" ||
|
} else if (cite_type == "citep" ||
|
||||||
cite_type == "citealp") {
|
cite_type == "citealp") {
|
||||||
if (engine == biblio::ENGINE_NATBIB_NUMERICAL) {
|
if (engine == ENGINE_NATBIB_NUMERICAL) {
|
||||||
label += *it + sep_str;
|
label += *it + sep_str;
|
||||||
} else {
|
} else {
|
||||||
label += author + ", " + year + sep_str;
|
label += author + ", " + year + sep_str;
|
||||||
@ -297,18 +297,18 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
// authors_last <before> year, <after>)
|
// authors_last <before> year, <after>)
|
||||||
} else if (cite_type == "citealt") {
|
} else if (cite_type == "citealt") {
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
case ENGINE_NATBIB_AUTHORYEAR:
|
||||||
label += author + ' ' + before_str +
|
label += author + ' ' + before_str +
|
||||||
year + sep_str;
|
year + sep_str;
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
case ENGINE_NATBIB_NUMERICAL:
|
||||||
label += author + ' ' + before_str + '#' + *it + sep_str;
|
label += author + ' ' + before_str + '#' + *it + sep_str;
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_JURABIB:
|
case ENGINE_JURABIB:
|
||||||
label += before_str + author + ' ' +
|
label += before_str + author + ' ' +
|
||||||
year + sep_str;
|
year + sep_str;
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_BASIC:
|
case ENGINE_BASIC:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
label.insert(label.size() - 1, after_str);
|
label.insert(label.size() - 1, after_str);
|
||||||
} else {
|
} else {
|
||||||
bool const add =
|
bool const add =
|
||||||
!(engine == biblio::ENGINE_NATBIB_NUMERICAL &&
|
!(engine == ENGINE_NATBIB_NUMERICAL &&
|
||||||
(cite_type == "citeauthor" ||
|
(cite_type == "citeauthor" ||
|
||||||
cite_type == "citeyear"));
|
cite_type == "citeyear"));
|
||||||
if (add)
|
if (add)
|
||||||
@ -345,7 +345,7 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cite_type == "citep" || cite_type == "citeyearpar" ||
|
if (cite_type == "citep" || cite_type == "citeyearpar" ||
|
||||||
(cite_type == "cite" && engine == biblio::ENGINE_BASIC) )
|
(cite_type == "cite" && engine == ENGINE_BASIC) )
|
||||||
label = op + label + cp;
|
label = op + label + cp;
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
@ -415,7 +415,7 @@ docstring InsetCitation::generateLabel() const
|
|||||||
docstring const after = getParam("after");
|
docstring const after = getParam("after");
|
||||||
|
|
||||||
docstring label;
|
docstring label;
|
||||||
biblio::CiteEngine const engine = buffer().params().citeEngine();
|
CiteEngine const engine = buffer().params().citeEngine();
|
||||||
label = complexLabel(buffer(), getCmdName(), getParam("key"),
|
label = complexLabel(buffer(), getCmdName(), getParam("key"),
|
||||||
before, after, engine);
|
before, after, engine);
|
||||||
|
|
||||||
@ -435,7 +435,7 @@ docstring InsetCitation::screenLabel() const
|
|||||||
|
|
||||||
void InsetCitation::updateLabels(ParIterator const &)
|
void InsetCitation::updateLabels(ParIterator const &)
|
||||||
{
|
{
|
||||||
biblio::CiteEngine const engine = buffer().params().citeEngine();
|
CiteEngine const engine = buffer().params().citeEngine();
|
||||||
if (cache.params == params() && cache.engine == engine)
|
if (cache.params == params() && cache.engine == engine)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ void InsetCitation::textString(odocstream & os) const
|
|||||||
// should revert to \cite[]{}
|
// should revert to \cite[]{}
|
||||||
int InsetCitation::latex(odocstream & os, OutputParams const &) const
|
int InsetCitation::latex(odocstream & os, OutputParams const &) const
|
||||||
{
|
{
|
||||||
biblio::CiteEngine cite_engine = buffer().params().citeEngine();
|
CiteEngine cite_engine = buffer().params().citeEngine();
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
docstring const cite_str = from_utf8(
|
docstring const cite_str = from_utf8(
|
||||||
asValidLatexCommand(getCmdName(), cite_engine));
|
asValidLatexCommand(getCmdName(), cite_engine));
|
||||||
@ -519,7 +519,7 @@ int InsetCitation::latex(odocstream & os, OutputParams const &) const
|
|||||||
|
|
||||||
docstring const & before = getParam("before");
|
docstring const & before = getParam("before");
|
||||||
docstring const & after = getParam("after");
|
docstring const & after = getParam("after");
|
||||||
if (!before.empty() && cite_engine != biblio::ENGINE_BASIC)
|
if (!before.empty() && cite_engine != ENGINE_BASIC)
|
||||||
os << '[' << before << "][" << after << ']';
|
os << '[' << before << "][" << after << ']';
|
||||||
else if (!after.empty())
|
else if (!after.empty())
|
||||||
os << '[' << after << ']';
|
os << '[' << after << ']';
|
||||||
@ -533,13 +533,13 @@ int InsetCitation::latex(odocstream & os, OutputParams const &) const
|
|||||||
void InsetCitation::validate(LaTeXFeatures & features) const
|
void InsetCitation::validate(LaTeXFeatures & features) const
|
||||||
{
|
{
|
||||||
switch (features.bufferParams().citeEngine()) {
|
switch (features.bufferParams().citeEngine()) {
|
||||||
case biblio::ENGINE_BASIC:
|
case ENGINE_BASIC:
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
case ENGINE_NATBIB_AUTHORYEAR:
|
||||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
case ENGINE_NATBIB_NUMERICAL:
|
||||||
features.require("natbib");
|
features.require("natbib");
|
||||||
break;
|
break;
|
||||||
case biblio::ENGINE_JURABIB:
|
case ENGINE_JURABIB:
|
||||||
features.require("jurabib");
|
features.require("jurabib");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ private:
|
|||||||
class Cache {
|
class Cache {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
Cache() : engine(biblio::ENGINE_BASIC), params(CITE_CODE) {}
|
Cache() : engine(ENGINE_BASIC), params(CITE_CODE) {}
|
||||||
///
|
///
|
||||||
biblio::CiteEngine engine;
|
CiteEngine engine;
|
||||||
///
|
///
|
||||||
InsetCommandParams params;
|
InsetCommandParams params;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user