#include "gettext.h"
#include "language.h"
#include "LaTeXFeatures.h"
-#include "latexrunparams.h"
#include "LColor.h"
#include "lyxlex.h"
#include "lyxrc.h"
#include "lyxtextclasslist.h"
+#include "outputparams.h"
#include "tex-strings.h"
#include "Spacing.h"
#include "texrow.h"
#include <boost/array.hpp>
-#include "support/std_sstream.h"
+#include <sstream>
namespace support = lyx::support;
using lyx::support::bformat;
using std::ostringstream;
using std::pair;
+namespace biblio = lyx::biblio;
+
struct BufferParams::Impl
{
orientation = ORIENTATION_PORTRAIT;
use_geometry = false;
use_amsmath = AMS_AUTO;
- use_natbib = false;
- use_numerical_citations = false;
+ cite_engine = biblio::ENGINE_BASIC;
+ use_bibtopic = false;
tracking_changes = false;
secnumdepth = 3;
tocdepth = 3;
lex.nextToken();
use_amsmath = static_cast<AMS>(
lex.getInteger());
- } else if (token == "\\use_natbib") {
+ } else if (token == "\\cite_engine") {
lex.nextToken();
- use_natbib = lex.getInteger();
- } else if (token == "\\use_numerical_citations") {
+ string const engine = lex.getString();
+
+ cite_engine = biblio::ENGINE_BASIC;
+ if (engine == "natbib_numerical")
+ cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
+ else if (engine == "natbib_authoryear")
+ cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+ else if (engine == "jurabib")
+ cite_engine = biblio::ENGINE_JURABIB;
+
+ } else if (token == "\\use_bibtopic") {
lex.nextToken();
- use_numerical_citations = lex.getInteger();
+ use_bibtopic = lex.getInteger();
} else if (token == "\\tracking_changes") {
lex.nextToken();
tracking_changes = lex.getInteger();
string const tok = lex.getString();
if (tok == "\\end_branch")
break;
+ Branch * branch_ptr = branchlist().find(branch);
if (tok == "\\selected") {
lex.nextToken();
- branchlist().setSelected(branch, lex.getInteger());
+ if (branch_ptr)
+ branch_ptr->setSelected(lex.getInteger());
}
// not yet operational
if (tok == "\\color") {
lex.nextToken();
string color = lex.getString();
- branchlist().setColor(branch, color);
+ if (branch_ptr)
+ branch_ptr->setColor(color);
// Update also the LColor table:
if (color == "none")
color = lcolor.getX11Name(LColor::background);
- lcolor.fill(static_cast<LColor::color>(lcolor.size()),
- branch, color);
+ lcolor.setColor(branch, color);
+
}
}
} else if (token == "\\author") {
spacing().writeFile(os);
+ string cite_engine_str = "basic";
+ switch (cite_engine) {
+ case biblio::ENGINE_BASIC:
+ break;
+ case biblio::ENGINE_NATBIB_NUMERICAL:
+ cite_engine_str = "natbib_numerical";
+ break;
+ case biblio::ENGINE_NATBIB_AUTHORYEAR:
+ cite_engine_str = "natbib_authoryear";
+ break;
+ case biblio::ENGINE_JURABIB:
+ cite_engine_str = "jurabib";
+ break;
+ }
+
os << "\\papersize " << string_papersize[papersize2]
<< "\n\\paperpackage " << string_paperpackages[paperpackage]
<< "\n\\use_geometry " << use_geometry
<< "\n\\use_amsmath " << use_amsmath
- << "\n\\use_natbib " << use_natbib
- << "\n\\use_numerical_citations " << use_numerical_citations
+ << "\n\\cite_engine " << cite_engine_str
+ << "\n\\use_bibtopic " << use_bibtopic
<< "\n\\paperorientation " << string_orientation[orientation]
<< '\n';
texrow.newline();
}
+ // If we use jurabib, we have to call babel here.
+ if (use_babel && features.isRequired("jurabib")) {
+ os << babelCall(language_options.str())
+ << '\n'
+ << features.getBabelOptions();
+ texrow.newline();
+ }
+
// Now insert the LyX specific LaTeX commands...
// The optional packages;
// We try to load babel late, in case it interferes
// with other packages.
- if (use_babel) {
- string tmp = lyxrc.language_package;
- if (!lyxrc.language_global_options
- && tmp == "\\usepackage{babel}")
- tmp = string("\\usepackage[") +
- language_options.str() +
- "]{babel}";
- lyxpreamble += tmp + "\n";
+ // Jurabib has to be called after babel, though.
+ if (use_babel && !features.isRequired("jurabib")) {
+ lyxpreamble += babelCall(language_options.str()) + '\n';
lyxpreamble += features.getBabelOptions();
}
result += ' ' + lyxrc.print_landscape_flag;
return result;
}
+
+
+string const BufferParams::babelCall(string const & lang_opts) const
+{
+ string tmp = lyxrc.language_package;
+ if (!lyxrc.language_global_options && tmp == "\\usepackage{babel}")
+ tmp = string("\\usepackage[") + lang_opts + "]{babel}";
+ return tmp;
+}