set infrastructure to allow not to call babel

This is a part of the fix for bug 3043.
I got the OK from Georg, that this patch doesn't introduce conflicts as it only sets the infrastructure.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18206 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2007-05-05 19:18:34 +00:00
parent 71d75896e0
commit c5527942f3
6 changed files with 40 additions and 18 deletions

View File

@ -964,7 +964,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
} // output_preamble
LYXERR(Debug::INFO) << "preamble finished, now the body." << endl;
if (!lyxrc.language_auto_begin) {
if (!lyxrc.language_auto_begin &&
!params().language->babel().empty()) {
// FIXME UNICODE
os << from_utf8(subst(lyxrc.language_command_begin,
"$$lang",
@ -993,7 +994,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
os << endl;
texrow().newline();
if (!lyxrc.language_auto_end) {
if (!lyxrc.language_auto_end &&
!params().language->babel().empty()) {
os << from_utf8(subst(lyxrc.language_command_end,
"$$lang",
params().language->babel()))

View File

@ -846,7 +846,11 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
bool const use_babel = features.useBabel();
if (use_babel) {
language_options << features.getLanguages();
language_options << language->babel();
if (!language->babel().empty()) {
if (!language_options.str().empty())
language_options << ',';
language_options << language->babel();
}
if (lyxrc.language_global_options)
clsoptions << language_options.str() << ',';
}

View File

@ -1176,14 +1176,21 @@ docstring Cursor::selectionAsString(bool label) const
if (startpit == endpit)
return pars[startpit].asString(buffer, startpos, endpos, label);
odocstringstream ods;
ods << "\n";
// only add blank line if we're not in an ERT inset
if (pars[startpit].ownerCode() != Inset::ERT_CODE)
ods << "\n";
docstring const parbreak = ods.str();
// First paragraph in selection
docstring result = pars[startpit].
asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
asString(buffer, startpos, pars[startpit].size(), label) + parbreak;
// The paragraphs in between (if any)
for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
Paragraph const & par = pars[pit];
result += par.asString(buffer, 0, par.size(), label) + "\n\n";
result += par.asString(buffer, 0, par.size(), label) + parbreak;
}
// Last paragraph in selection

View File

@ -752,7 +752,7 @@ int Font::latexWriteStartChanges(odocstream & os, Font const & base,
os << "\\L{";
count += 3;
}
} else {
} else if (!language()->babel().empty()) {
string const tmp =
subst(lyxrc.language_command_local,
"$$lang", language()->babel());

View File

@ -191,7 +191,8 @@ LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
bool LaTeXFeatures::useBabel() const
{
return lyxrc.language_use_babel ||
bufferParams().language->lang() != lyxrc.default_language ||
(bufferParams().language->lang() != lyxrc.default_language &&
!bufferParams().language->babel().empty()) ||
this->hasLanguages();
}
@ -322,7 +323,8 @@ void LaTeXFeatures::useFloat(string const & name)
void LaTeXFeatures::useLanguage(Language const * lang)
{
UsedLanguages_.insert(lang);
if (!lang->babel().empty())
UsedLanguages_.insert(lang);
}

View File

@ -105,7 +105,8 @@ TeXEnvironment(Buffer const & buf,
if (par_language->babel() != prev_par_language->babel()) {
if (!lyxrc.language_command_end.empty() &&
prev_par_language->babel() != doc_language->babel()) {
prev_par_language->babel() != doc_language->babel() &&
!prev_par_language->babel().empty()) {
os << from_ascii(subst(
lyxrc.language_command_end,
"$$lang",
@ -115,7 +116,8 @@ TeXEnvironment(Buffer const & buf,
}
if (lyxrc.language_command_end.empty() ||
par_language->babel() != doc_language->babel()) {
par_language->babel() != doc_language->babel() &&
!par_language->babel().empty()) {
os << from_ascii(subst(
lyxrc.language_command_begin,
"$$lang",
@ -271,7 +273,8 @@ TeXOnePar(Buffer const & buf,
|| boost::prior(pit)->getDepth() < pit->getDepth())))
{
if (!lyxrc.language_command_end.empty() &&
prev_par_language->babel() != doc_language->babel())
prev_par_language->babel() != doc_language->babel() &&
!prev_par_language->babel().empty())
{
os << from_ascii(subst(lyxrc.language_command_end,
"$$lang",
@ -281,7 +284,8 @@ TeXOnePar(Buffer const & buf,
}
if (lyxrc.language_command_end.empty() ||
par_language->babel() != doc_language->babel())
par_language->babel() != doc_language->babel() &&
!par_language->babel().empty())
{
os << from_ascii(subst(
lyxrc.language_command_begin,
@ -456,12 +460,15 @@ TeXOnePar(Buffer const & buf,
os << '\n';
texrow.newline();
}
if (lyxrc.language_command_end.empty())
os << from_ascii(subst(
lyxrc.language_command_begin,
"$$lang",
doc_language->babel()));
else
if (lyxrc.language_command_end.empty()) {
if (!doc_language->babel().empty()) {
os << from_ascii(subst(
lyxrc.language_command_begin,
"$$lang",
doc_language->babel()));
pending_newline = true;
}
} else if (!par_language->babel().empty())
os << from_ascii(subst(
lyxrc.language_command_end,
"$$lang",