Refine fix for bug #7800. Don't use \inputencoding with unicode backends.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40607 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2012-01-13 00:52:03 +00:00
parent a6f843aacb
commit 08ba2b9b45
3 changed files with 24 additions and 15 deletions

View File

@ -1153,7 +1153,8 @@ docstring const LaTeXFeatures::getTClassHTMLStyles() const
namespace {
docstring const getFloatI18nPreamble(docstring const & type,
docstring const & name, Language const * lang,
Encoding const & enc, bool const polyglossia)
Encoding const & enc, bool const polyglossia,
bool const unicode)
{
docstring const language = polyglossia ? from_ascii(lang->polyglossia())
: from_ascii(lang->babel());
@ -1162,7 +1163,7 @@ docstring const getFloatI18nPreamble(docstring const & type,
docstring const bufenc = from_ascii(enc.iconvName());
docstring const s1 = docstring(1, 0xF0000);
docstring const s2 = docstring(1, 0xF0001);
docstring const translated = (langenc == bufenc) ? name
docstring const translated = (unicode || langenc == bufenc) ? name
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
+ s1 + langenc + s2 + name + s1 + bufenc + s2;
@ -1189,18 +1190,21 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
// language dependent commands (once per document)
snippets.insert(tclass[*cit].langpreamble(buffer().language(),
buffer().params().encoding(),
use_polyglossia));
use_polyglossia,
runparams().isFullUnicode()));
// commands for language changing (for multilanguage documents)
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
snippets.insert(tclass[*cit].babelpreamble(
buffer().language(),
buffer().params().encoding(),
use_polyglossia));
use_polyglossia,
runparams().isFullUnicode()));
for (lang_it lit = lbeg; lit != lend; ++lit)
snippets.insert(tclass[*cit].babelpreamble(
*lit,
buffer().params().encoding(),
use_polyglossia));
use_polyglossia,
runparams().isFullUnicode()));
}
}
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
@ -1221,7 +1225,8 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
snippets.insert(getFloatI18nPreamble(
type, name, buffer().language(),
buffer().params().encoding(),
use_polyglossia));
use_polyglossia,
runparams().isFullUnicode()));
for (lang_it lit = lbeg; lit != lend; ++lit) {
string const code = (*lit)->code();
name = (*lit)->translateLayout(fl.name());
@ -1236,7 +1241,8 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
snippets.insert(getFloatI18nPreamble(
type, name, *lit,
buffer().params().encoding(),
use_polyglossia));
use_polyglossia,
runparams().isFullUnicode()));
}
}
}

View File

@ -862,7 +862,8 @@ void Layout::readSpacing(Lexer & lex)
namespace {
docstring const i18npreamble(Language const * lang, Encoding const & enc,
docstring const & templ, bool const polyglossia)
docstring const & templ, bool const polyglossia,
bool const unicode)
{
if (templ.empty())
return templ;
@ -890,7 +891,7 @@ docstring const i18npreamble(Language const * lang, Encoding const & enc,
while (regex_search(preamble, sub, reg)) {
string const key = sub.str(1);
string translated = to_utf8(lang->translateLayout(key));
if (langenc != bufenc)
if (!unicode && langenc != bufenc)
translated = "\\inputencoding{" + texenc + "}"
+ s1 + langenc + s2 + translated
+ s1 + bufenc + s2;
@ -904,16 +905,18 @@ docstring const i18npreamble(Language const * lang, Encoding const & enc,
docstring const Layout::langpreamble(Language const * lang,
Encoding const & enc, bool const polyglossia) const
Encoding const & enc, bool const polyglossia,
bool const unicode) const
{
return i18npreamble(lang, enc, langpreamble_, polyglossia);
return i18npreamble(lang, enc, langpreamble_, polyglossia, unicode);
}
docstring const Layout::babelpreamble(Language const * lang,
Encoding const & enc, bool const polyglossia) const
Encoding const & enc, bool const polyglossia,
bool const unicode) const
{
return i18npreamble(lang, enc, babelpreamble_, polyglossia);
return i18npreamble(lang, enc, babelpreamble_, polyglossia, unicode);
}

View File

@ -96,10 +96,10 @@ public:
docstring const & preamble() const { return preamble_; }
/// Get language dependent macro definitions needed for this layout
/// for language \p lang
docstring const langpreamble(Language const * lang, Encoding const & enc, bool const polyglossia) const;
docstring const langpreamble(Language const * lang, Encoding const & enc, bool const polyglossia, bool const unicode) const;
/// Get language and babel dependent macro definitions needed for
/// this layout for language \p lang
docstring const babelpreamble(Language const * lang, Encoding const & enc, bool const polyglossia) const;
docstring const babelpreamble(Language const * lang, Encoding const & enc, bool const polyglossia, bool const unicode) const;
///
std::set<std::string> const & requires() const { return requires_; }
///