Consider class-provided citation engines

Do not attempt to load, nor allow to set, a different engine in this
case.

Fixes: #11022
This commit is contained in:
Juergen Spitzmueller 2018-02-08 13:25:19 +01:00
parent 84658d37e2
commit 2f6ada6644
4 changed files with 41 additions and 3 deletions

View File

@ -2322,7 +2322,11 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
}
// ... but before biblatex (see #7065)
if (features.mustProvide("biblatex")) {
if (features.mustProvide("biblatex")
&& !features.isProvided("biblatex-natbib")
&& !features.isProvided("natbib-internal")
&& !features.isProvided("natbib")
&& !features.isProvided("jurabib")) {
string delim = "";
string opts;
os << "\\usepackage";

View File

@ -1231,7 +1231,11 @@ string const LaTeXFeatures::getPackages() const
// Some classes load natbib themselves, but still allow (or even require)
// plain numeric citations (ReVTeX is such a case, see bug 5182).
// This special case is indicated by the "natbib-internal" key.
if (mustProvide("natbib") && !isProvided("natbib-internal")) {
if (mustProvide("natbib")
&& !isProvided("natbib-internal")
&& !isProvided("biblatex")
&& !isProvided("biblatex-natbib")
&& !isProvided("jurabib")) {
packages << "\\usepackage[";
if (params_.citeEngineType() == ENGINE_TYPE_NUMERICAL)
packages << "numbers";
@ -1250,7 +1254,11 @@ string const LaTeXFeatures::getPackages() const
}
// jurabib -- we need version 0.6 at least.
if (mustProvide("jurabib")) {
if (mustProvide("jurabib")
&& !isProvided("natbib-internal")
&& !isProvided("natbib")
&& !isProvided("biblatex")
&& !isProvided("biblatex-natbib")) {
packages << "\\usepackage";
if (!params_.biblio_opts.empty())
packages << '[' << params_.biblio_opts << ']';

View File

@ -2445,6 +2445,28 @@ void GuiDocument::biblioChanged()
}
void GuiDocument::checkPossibleCiteEngines()
{
// Check if the class provides a specific engine,
// and if so, enforce this.
string force_engine;
if (documentClass().provides("natbib")
|| documentClass().provides("natbib-internal"))
force_engine = "natbib";
else if (documentClass().provides("jurabib"))
force_engine = "jurabib";
else if (documentClass().provides("biblatex"))
force_engine = "biblatex";
else if (documentClass().provides("biblatex-natbib"))
force_engine = "biblatex-natbib";
if (!force_engine.empty())
biblioModule->citeEngineCO->setCurrentIndex(
biblioModule->citeEngineCO->findData(toqstr(force_engine)));
biblioModule->citeEngineCO->setEnabled(force_engine.empty());
}
void GuiDocument::rescanBibFiles()
{
if (isBiblatex())
@ -3326,6 +3348,8 @@ void GuiDocument::paramsToDialog()
updateEngineType(documentClass().opt_enginetype(),
bp_.citeEngineType());
checkPossibleCiteEngines();
biblioModule->citeStyleCO->setCurrentIndex(
biblioModule->citeStyleCO->findData(bp_.citeEngineType()));

View File

@ -296,6 +296,8 @@ private:
///
bool isBiblatex() const;
///
void checkPossibleCiteEngines();
///
BufferParams bp_;
/// List of names of available modules
std::list<modInfoStruct> moduleNames_;