odocstream & os, TexRow & texrow,
OutputParams const & runparams)
{
- lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
+ LYXERR(Debug::LATEX) << "TeXDeeper... " << &*pit << endl;
ParagraphList::const_iterator par = pit;
while (par != paragraphs.end() &&
os, texrow, runparams);
}
}
- lyxerr[Debug::LATEX] << "TeXDeeper...done " << endl;
+ LYXERR(Debug::LATEX) << "TeXDeeper...done " << endl;
return par;
}
odocstream & os, TexRow & texrow,
OutputParams const & runparams)
{
- lyxerr[Debug::LATEX] << "TeXEnvironment... " << &*pit << endl;
+ LYXERR(Debug::LATEX) << "TeXEnvironment... " << &*pit << endl;
BufferParams const & bparams = buf.params();
texrow.newline();
}
- if (par != paragraphs.end() && lyxerr.debugging(Debug::LATEX))
- lyxerr << "TeXEnvironment...done " << &*par << endl;
+ if (par != paragraphs.end())
+ LYXERR(Debug::LATEX) << "TeXEnvironment...done " << &*par << endl;
return par;
}
OutputParams const & runparams_in,
string const & everypar)
{
- lyxerr[Debug::LATEX] << "TeXOnePar... " << &*pit << " '"
+ LYXERR(Debug::LATEX) << "TeXOnePar... " << &*pit << " '"
<< everypar << "'" << endl;
BufferParams const & bparams = buf.params();
LyXLayout_ptr style;
}
}
+ // Switch file encoding if necessary
+ if (bparams.inputenc == "auto") {
+ // Look ahead for future encoding changes.
+ // We try to output them at the beginning of the paragraph,
+ // since the \inputencoding command is not allowed e.g. in
+ // sections.
+ for (pos_type i = 0; i < pit->size(); ++i) {
+ char_type const c = pit->getChar(i);
+ if (c < 0x80)
+ continue;
+ if (pit->isInset(i))
+ break;
+ // All characters before c are in the ASCII range, and
+ // c is non-ASCII (but no inset), so change the
+ // encoding to that required by the language of c.
+ Encoding const * const encoding =
+ pit->getFontSettings(bparams, i).language()->encoding();
+ if (switchEncoding(os, bparams, false,
+ *(runparams.encoding), *encoding) > 0) {
+ runparams.encoding = encoding;
+ os << '\n';
+ texrow.newline();
+ }
+ break;
+ }
+ }
+
// In an inset with unlimited length (all in one row),
// don't allow any special options in the paragraph
if (!pit->forceDefaultParagraphs()) {
// FIXME UNICODE
os << from_utf8(everypar);
bool need_par = pit->simpleTeXOnePar(buf, bparams, outerfont,
- // *encoding,
os, texrow, runparams);
// Make sure that \\par is done with the font of the last
texrow.newline();
}
- if (boost::next(pit) != paragraphs.end() &&
- lyxerr.debugging(Debug::LATEX))
- lyxerr << "TeXOnePar...done " << &*boost::next(pit) << endl;
+ if (boost::next(pit) != paragraphs.end())
+ LYXERR(Debug::LATEX) << "TeXOnePar...done " << &*boost::next(pit) << endl;
return ++pit;
}
int switchEncoding(odocstream & os, BufferParams const & bparams,
- Encoding const & oldEnc, Encoding const & newEnc)
+ bool moving_arg, Encoding const & oldEnc,
+ Encoding const & newEnc)
{
// FIXME thailatex does not support the inputenc package, so we
// ignore switches from/to tis620-0 encoding here. This does of
// course only work as long as the non-thai text contains ASCII
// only, but it is the best we can do.
- if ((bparams.inputenc == "auto" || bparams.inputenc == "default") &&
+ // Since the \inputencoding command does not work inside sections
+ // we ignore the encoding switch also in moving arguments.
+ if (((bparams.inputenc == "auto" && !moving_arg) ||
+ bparams.inputenc == "default") &&
oldEnc.name() != newEnc.name() &&
oldEnc.name() != "ascii" && newEnc.name() != "ascii" &&
oldEnc.name() != "tis620-0" && newEnc.name() != "tis620-0") {
- lyxerr[Debug::LATEX] << "Changing LaTeX encoding from "
+ LYXERR(Debug::LATEX) << "Changing LaTeX encoding from "
<< oldEnc.name() << " to "
<< newEnc.name() << endl;
os << setEncoding(newEnc.iconvName());