mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Refine fix for bug #7800. Also allow setting the document encoding to
an encoding different from the automatically chosen one. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39823 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6c85f8338f
commit
8edfef001d
@ -1164,18 +1164,18 @@ docstring const LaTeXFeatures::getTClassHTMLStyles() const {
|
||||
namespace {
|
||||
docstring const getFloatI18nPreamble(docstring const & type,
|
||||
docstring const & name, Language const * lang,
|
||||
Language const * buflang, bool const polyglossia)
|
||||
Encoding const & enc, bool const polyglossia)
|
||||
{
|
||||
docstring const language = polyglossia ? from_ascii(lang->polyglossia())
|
||||
: from_ascii(lang->babel());
|
||||
docstring const enc = from_ascii(lang->encoding()->iconvName());
|
||||
docstring const langenc = from_ascii(lang->encoding()->iconvName());
|
||||
docstring const texenc = from_ascii(lang->encoding()->latexName());
|
||||
docstring const bufenc = from_ascii(buflang->encoding()->iconvName());
|
||||
docstring const translated = (enc == bufenc) ? name
|
||||
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
|
||||
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
|
||||
+ docstring(1, 0xF0000) + enc + docstring(1, 0xF0001)
|
||||
+ translated
|
||||
+ docstring(1, 0xF0000) + bufenc + docstring(1, 0xF0001);
|
||||
+ s1 + langenc + s2 + translated + s1 + bufenc + s2;
|
||||
|
||||
odocstringstream os;
|
||||
os << "\\addto\\captions" << language
|
||||
@ -1199,18 +1199,19 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
|
||||
for (; cit != end; ++cit) {
|
||||
// language dependent commands (once per document)
|
||||
snippets.insert(tclass[*cit].langpreamble(buffer().language(),
|
||||
use_polyglossia));
|
||||
buffer().params().encoding(),
|
||||
use_polyglossia));
|
||||
// commands for language changing (for multilanguage documents)
|
||||
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
||||
snippets.insert(tclass[*cit].babelpreamble(
|
||||
buffer().language(),
|
||||
buffer().language(),
|
||||
use_polyglossia));
|
||||
buffer().language(),
|
||||
buffer().params().encoding(),
|
||||
use_polyglossia));
|
||||
for (lang_it lit = lbeg; lit != lend; ++lit)
|
||||
snippets.insert(tclass[*cit].babelpreamble(
|
||||
*lit,
|
||||
buffer().language(),
|
||||
use_polyglossia));
|
||||
*lit,
|
||||
buffer().params().encoding(),
|
||||
use_polyglossia));
|
||||
}
|
||||
}
|
||||
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
||||
@ -1229,8 +1230,9 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
|
||||
// (that differs from the source)
|
||||
if (flname != name)
|
||||
snippets.insert(getFloatI18nPreamble(
|
||||
type, name, buffer().language(),
|
||||
buffer().language(), use_polyglossia));
|
||||
type, name, buffer().language(),
|
||||
buffer().params().encoding(),
|
||||
use_polyglossia));
|
||||
for (lang_it lit = lbeg; lit != lend; ++lit) {
|
||||
string const code = (*lit)->code();
|
||||
name = (*lit)->translateLayout(fl.name());
|
||||
@ -1243,9 +1245,9 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
|
||||
(flname != name || contains(code, "en"));
|
||||
if (have_translation)
|
||||
snippets.insert(getFloatI18nPreamble(
|
||||
type, name, *lit,
|
||||
buffer().language(),
|
||||
use_polyglossia));
|
||||
type, name, *lit,
|
||||
buffer().params().encoding(),
|
||||
use_polyglossia));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ void Layout::readSpacing(Lexer & lex)
|
||||
|
||||
namespace {
|
||||
|
||||
docstring const i18npreamble(Language const * lang, Language const * buflang,
|
||||
docstring const i18npreamble(Language const * lang, Encoding const & enc,
|
||||
docstring const & templ, bool const polyglossia)
|
||||
{
|
||||
if (templ.empty())
|
||||
@ -875,9 +875,9 @@ docstring const i18npreamble(Language const * lang, Language const * buflang,
|
||||
// tex2lyx does not have getMessages()
|
||||
LASSERT(false, /**/);
|
||||
#else
|
||||
string const enc = lang->encoding()->iconvName();
|
||||
string const langenc = lang->encoding()->iconvName();
|
||||
string const texenc = lang->encoding()->latexName();
|
||||
string const bufenc = buflang->encoding()->iconvName();
|
||||
string const bufenc = enc.iconvName();
|
||||
// First and second character of plane 15 (Private Use Area)
|
||||
char const s1[5] = {0xf3, 0xb0, 0x80, 0x80, 0x00}; // U+F0000
|
||||
char const s2[5] = {0xf3, 0xb0, 0x80, 0x81, 0x00}; // U+F0001
|
||||
@ -889,9 +889,9 @@ docstring const i18npreamble(Language const * lang, Language const * buflang,
|
||||
while (regex_search(preamble, sub, reg)) {
|
||||
string const key = sub.str(1);
|
||||
string translated = to_utf8(lang->translateLayout(key));
|
||||
if (enc != bufenc)
|
||||
if (langenc != bufenc)
|
||||
translated = "\\inputencoding{" + texenc + "}"
|
||||
+ string(s1) + enc + string(s2) + translated
|
||||
+ string(s1) + langenc + string(s2) + translated
|
||||
+ string(s1) + bufenc + string(s2);
|
||||
preamble = subst(preamble, sub.str(), translated);
|
||||
}
|
||||
@ -902,16 +902,17 @@ docstring const i18npreamble(Language const * lang, Language const * buflang,
|
||||
}
|
||||
|
||||
|
||||
docstring const Layout::langpreamble(Language const * lang, bool const polyglossia) const
|
||||
docstring const Layout::langpreamble(Language const * lang,
|
||||
Encoding const & enc, bool const polyglossia) const
|
||||
{
|
||||
return i18npreamble(lang, lang, langpreamble_, polyglossia);
|
||||
return i18npreamble(lang, enc, langpreamble_, polyglossia);
|
||||
}
|
||||
|
||||
|
||||
docstring const Layout::babelpreamble(Language const * lang,
|
||||
Language const * buflang, bool const polyglossia) const
|
||||
Encoding const & enc, bool const polyglossia) const
|
||||
{
|
||||
return i18npreamble(lang, buflang, babelpreamble_, polyglossia);
|
||||
return i18npreamble(lang, enc, babelpreamble_, polyglossia);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef LAYOUT_H
|
||||
#define LAYOUT_H
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "FontInfo.h"
|
||||
#include "LayoutEnums.h"
|
||||
#include "Spacing.h"
|
||||
@ -95,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, bool const polyglossia) const;
|
||||
docstring const langpreamble(Language const * lang, Encoding const & enc, bool const polyglossia) const;
|
||||
/// Get language and babel dependent macro definitions needed for
|
||||
/// this layout for language \p lang
|
||||
docstring const babelpreamble(Language const * lang, Language const * buflang, bool const polyglossia) const;
|
||||
docstring const babelpreamble(Language const * lang, Encoding const & enc, bool const polyglossia) const;
|
||||
///
|
||||
std::set<std::string> const & requires() const { return requires_; }
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user