#include "Buffer.h"
#include "buffer_funcs.h"
#include "Bullet.h"
+#include "CiteEnginesList.h"
#include "Color.h"
#include "ColorSet.h"
#include "Converter.h"
static char const * const string_quotes_style[] = {
- "english", "swedish", "german", "polish", "french", "danish", ""
+ "english", "swedish", "german", "polish", "swiss", "danish", "plain",
+ "british", "swedishg", "french", "frenchin", "russian", "cjk", "cjkangle", ""
};
// Quotes style
-typedef Translator<string, InsetQuotes::QuoteStyle> QuotesStyleTranslator;
+typedef Translator<string, InsetQuotesParams::QuoteStyle> QuotesStyleTranslator;
QuotesStyleTranslator const init_quotesstyletranslator()
{
QuotesStyleTranslator translator
- (string_quotes_style[0], InsetQuotes::EnglishQuotes);
- translator.addPair(string_quotes_style[1], InsetQuotes::SwedishQuotes);
- translator.addPair(string_quotes_style[2], InsetQuotes::GermanQuotes);
- translator.addPair(string_quotes_style[3], InsetQuotes::PolishQuotes);
- translator.addPair(string_quotes_style[4], InsetQuotes::FrenchQuotes);
- translator.addPair(string_quotes_style[5], InsetQuotes::DanishQuotes);
+ (string_quotes_style[0], InsetQuotesParams::EnglishQuotes);
+ translator.addPair(string_quotes_style[1], InsetQuotesParams::SwedishQuotes);
+ translator.addPair(string_quotes_style[2], InsetQuotesParams::GermanQuotes);
+ translator.addPair(string_quotes_style[3], InsetQuotesParams::PolishQuotes);
+ translator.addPair(string_quotes_style[4], InsetQuotesParams::SwissQuotes);
+ translator.addPair(string_quotes_style[5], InsetQuotesParams::DanishQuotes);
+ translator.addPair(string_quotes_style[6], InsetQuotesParams::PlainQuotes);
+ translator.addPair(string_quotes_style[7], InsetQuotesParams::BritishQuotes);
+ translator.addPair(string_quotes_style[8], InsetQuotesParams::SwedishGQuotes);
+ translator.addPair(string_quotes_style[9], InsetQuotesParams::FrenchQuotes);
+ translator.addPair(string_quotes_style[10], InsetQuotesParams::FrenchINQuotes);
+ translator.addPair(string_quotes_style[11], InsetQuotesParams::RussianQuotes);
+ translator.addPair(string_quotes_style[12], InsetQuotesParams::CJKQuotes);
+ translator.addPair(string_quotes_style[13], InsetQuotesParams::CJKAngleQuotes);
return translator;
}
}
-// Cite engine
-typedef Translator<string, CiteEngineType> CiteEngineTypeTranslator;
-
-
-CiteEngineTypeTranslator const init_citeenginetypetranslator()
-{
- CiteEngineTypeTranslator translator("authoryear", ENGINE_TYPE_AUTHORYEAR);
- translator.addPair("numerical", ENGINE_TYPE_NUMERICAL);
- translator.addPair("default", ENGINE_TYPE_DEFAULT);
- return translator;
-}
-
-
-CiteEngineTypeTranslator const & citeenginetypetranslator()
-{
- static CiteEngineTypeTranslator const translator =
- init_citeenginetypetranslator();
- return translator;
-}
-
-
// Spacing
typedef Translator<string, Spacing::Space> SpaceTranslator;
cite_engine_type_ = ENGINE_TYPE_DEFAULT;
makeDocumentClass();
paragraph_separation = ParagraphIndentSeparation;
- quotes_style = InsetQuotes::EnglishQuotes;
+ quotes_style = InsetQuotesParams::EnglishQuotes;
+ dynamic_quotes = false;
fontsize = "default";
/* PaperLayout */
string qstyle;
lex >> qstyle;
quotes_style = quotesstyletranslator().find(qstyle);
+ } else if (token == "\\dynamic_quotes") {
+ lex >> dynamic_quotes;
} else if (token == "\\papersize") {
string ppsize;
lex >> ppsize;
} else if (token == "\\cite_engine_type") {
string engine_type;
lex >> engine_type;
- cite_engine_type_ = citeenginetypetranslator().find(engine_type);
+ cite_engine_type_ = theCiteEnginesList.getType(engine_type);
} else if (token == "\\biblio_style") {
lex.eatLine();
biblio_style = lex.getString();
+ } else if (token == "\\biblio_options") {
+ lex.eatLine();
+ biblio_opts = trim(lex.getString());
+ } else if (token == "\\biblatex_bibstyle") {
+ lex.eatLine();
+ biblatex_bibstyle = trim(lex.getString());
+ } else if (token == "\\biblatex_citestyle") {
+ lex.eatLine();
+ biblatex_citestyle = trim(lex.getString());
} else if (token == "\\use_bibtopic") {
lex >> use_bibtopic;
} else if (token == "\\use_indices") {
os << "basic";
}
- os << "\n\\cite_engine_type " << citeenginetypetranslator().find(cite_engine_type_)
- << "\n\\biblio_style " << biblio_style
- << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
+ os << "\n\\cite_engine_type " << theCiteEnginesList.getTypeAsString(cite_engine_type_);
+
+ if (!biblio_style.empty())
+ os << "\n\\biblio_style " << biblio_style;
+ if (!biblio_opts.empty())
+ os << "\n\\biblio_options " << biblio_opts;
+ if (!biblatex_bibstyle.empty())
+ os << "\n\\biblatex_bibstyle " << biblatex_bibstyle;
+ if (!biblatex_citestyle.empty())
+ os << "\n\\biblatex_citestyle " << biblatex_citestyle;
+
+ os << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
<< "\n\\use_indices " << convert<string>(use_indices)
<< "\n\\paperorientation " << string_orientation[orientation]
<< "\n\\suppress_date " << convert<string>(suppress_date)
os << "\n\\defskip " << getDefSkip().asLyXCommand();
os << "\n\\quotes_style "
<< string_quotes_style[quotes_style]
+ << "\n\\dynamic_quotes " << dynamic_quotes
<< "\n\\papercolumns " << columns
<< "\n\\papersides " << sides
<< "\n\\paperpagestyle " << pagestyle << '\n';
&& useNonTeXFonts)
os << "\\usepackage{xunicode}\n";
- // Polyglossia must be loaded last
+ // Polyglossia must be loaded last ...
if (use_polyglossia) {
// call the package
os << "\\usepackage{polyglossia}\n";
}
}
+ // ... but before biblatex (see #7065)
+ if (features.mustProvide("biblatex")) {
+ string delim = "";
+ string opts;
+ os << "\\usepackage";
+ if (!biblatex_bibstyle.empty()
+ && (biblatex_bibstyle == biblatex_citestyle)) {
+ opts = "style=" + biblatex_bibstyle;
+ delim = ",";
+ } else {
+ if (!biblatex_bibstyle.empty()) {
+ opts = "bibstyle=" + biblatex_bibstyle;
+ delim = ",";
+ }
+ if (!biblatex_citestyle.empty()) {
+ opts += delim + "citestyle=" + biblatex_citestyle;
+ delim = ",";
+ }
+ }
+ if (bibtexCommand() == "bibtex8"
+ || prefixIs(bibtexCommand(), "bibtex8 ")) {
+ opts += delim + "backend=bibtex8";
+ delim = ",";
+ } else if (bibtexCommand() == "bibtex"
+ || prefixIs(bibtexCommand(), "bibtex ")) {
+ opts += delim + "backend=bibtex";
+ delim = ",";
+ }
+ if (!biblio_opts.empty())
+ opts += delim + biblio_opts;
+ if (!opts.empty())
+ os << "[" << opts << "]";
+ os << "{biblatex}\n";
+ }
+
+
// Load custom language package here
if (features.langPackage() == LaTeXFeatures::LANG_PACK_CUSTOM) {
if (lang_package == "default")
invalidateConverterCache();
LayoutModuleList mods;
+ LayoutModuleList ces;
LayoutModuleList::iterator it = layout_modules_.begin();
LayoutModuleList::iterator en = layout_modules_.end();
for (; it != en; ++it)
it = cite_engine_.begin();
en = cite_engine_.end();
for (; it != en; ++it)
- mods.push_back(*it);
+ ces.push_back(*it);
- doc_class_ = getDocumentClass(*baseClass(), mods, clone);
+ doc_class_ = getDocumentClass(*baseClass(), mods, ces, clone);
TextClass::ReturnValues success = TextClass::OK;
if (!forced_local_layout_.empty())
}
-InsetQuotes::QuoteStyle BufferParams::getQuoteStyle(string const & qs) const
+InsetQuotesParams::QuoteStyle BufferParams::getQuoteStyle(string const & qs) const
{
return quotesstyletranslator().find(qs);
}
string const & BufferParams::defaultBiblioStyle() const
{
- return documentClass().defaultBiblioStyle();
+ map<string, string> bs = documentClass().defaultBiblioStyle();
+ return bs[theCiteEnginesList.getTypeAsString(citeEngineType())];
}
}
+string BufferParams::getCiteAlias(string const & s) const
+{
+ vector<string> commands =
+ documentClass().citeCommands(citeEngineType());
+ // If it is a real command, don't treat it as an alias
+ if (find(commands.begin(), commands.end(), s) != commands.end())
+ return string();
+ map<string,string> aliases = documentClass().citeCommandAliases();
+ if (aliases.find(s) != aliases.end())
+ return aliases[s];
+ return string();
+}
+
+
void BufferParams::setCiteEngine(string const & engine)
{
clearCiteEngine();
vector<string> commands =
documentClass().citeCommands(citeEngineType());
if (commands.empty())
- commands.push_back(default_style.cmd);
+ commands.push_back(default_style.name);
return commands;
}
return styles;
}
+
+string const BufferParams::bibtexCommand() const
+{
+ // Return document-specific setting if available
+ if (bibtex_command != "default")
+ return bibtex_command;
+
+ // If we have "default" in document settings, consult the prefs
+ // 1. Japanese (uses a specific processor)
+ if (encoding().package() == Encoding::japanese) {
+ if (lyxrc.jbibtex_command != "automatic")
+ // Return the specified program, if "automatic" is not set
+ return lyxrc.jbibtex_command;
+ else if (!useBiblatex()) {
+ // With classic BibTeX, return pbibtex, jbibtex, bibtex
+ if (lyxrc.jbibtex_alternatives.find("pbibtex") != lyxrc.jbibtex_alternatives.end())
+ return "pbibtex";
+ if (lyxrc.jbibtex_alternatives.find("jbibtex") != lyxrc.jbibtex_alternatives.end())
+ return "jbibtex";
+ return "bibtex";
+ }
+ }
+ // 2. All other languages
+ else if (lyxrc.bibtex_command != "automatic")
+ // Return the specified program, if "automatic" is not set
+ return lyxrc.bibtex_command;
+
+ // 3. Automatic: find the most suitable for the current cite framework
+ if (useBiblatex()) {
+ // For Biblatex, we prefer biber (also for Japanese)
+ // and fall back to bibtex8 and, as last resort, bibtex
+ if (lyxrc.bibtex_alternatives.find("biber") != lyxrc.bibtex_alternatives.end())
+ return "biber";
+ else if (lyxrc.bibtex_alternatives.find("bibtex8") != lyxrc.bibtex_alternatives.end())
+ return "bibtex8";
+ }
+ return "bibtex";
+}
+
+
+bool BufferParams::useBiblatex() const
+{
+ return theCiteEnginesList[citeEngine().list().front()]
+ ->getCiteFramework() == "biblatex";
+}
+
+
void BufferParams::invalidateConverterCache() const
{
pimpl_->isExportCacheValid = false;