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