mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +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 {
|
namespace {
|
||||||
docstring const getFloatI18nPreamble(docstring const & type,
|
docstring const getFloatI18nPreamble(docstring const & type,
|
||||||
docstring const & name, Language const * lang,
|
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())
|
docstring const language = polyglossia ? from_ascii(lang->polyglossia())
|
||||||
: from_ascii(lang->babel());
|
: 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 texenc = from_ascii(lang->encoding()->latexName());
|
||||||
docstring const bufenc = from_ascii(buflang->encoding()->iconvName());
|
docstring const bufenc = from_ascii(enc.iconvName());
|
||||||
docstring const translated = (enc == bufenc) ? name
|
docstring const s1 = docstring(1, 0xF0000);
|
||||||
|
docstring const s2 = docstring(1, 0xF0001);
|
||||||
|
docstring const translated = (langenc == bufenc) ? name
|
||||||
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
|
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
|
||||||
+ docstring(1, 0xF0000) + enc + docstring(1, 0xF0001)
|
+ s1 + langenc + s2 + translated + s1 + bufenc + s2;
|
||||||
+ translated
|
|
||||||
+ docstring(1, 0xF0000) + bufenc + docstring(1, 0xF0001);
|
|
||||||
|
|
||||||
odocstringstream os;
|
odocstringstream os;
|
||||||
os << "\\addto\\captions" << language
|
os << "\\addto\\captions" << language
|
||||||
@ -1199,17 +1199,18 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
|
|||||||
for (; cit != end; ++cit) {
|
for (; cit != end; ++cit) {
|
||||||
// language dependent commands (once per document)
|
// language dependent commands (once per document)
|
||||||
snippets.insert(tclass[*cit].langpreamble(buffer().language(),
|
snippets.insert(tclass[*cit].langpreamble(buffer().language(),
|
||||||
|
buffer().params().encoding(),
|
||||||
use_polyglossia));
|
use_polyglossia));
|
||||||
// commands for language changing (for multilanguage documents)
|
// commands for language changing (for multilanguage documents)
|
||||||
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
if ((use_babel || use_polyglossia) && !UsedLanguages_.empty()) {
|
||||||
snippets.insert(tclass[*cit].babelpreamble(
|
snippets.insert(tclass[*cit].babelpreamble(
|
||||||
buffer().language(),
|
buffer().language(),
|
||||||
buffer().language(),
|
buffer().params().encoding(),
|
||||||
use_polyglossia));
|
use_polyglossia));
|
||||||
for (lang_it lit = lbeg; lit != lend; ++lit)
|
for (lang_it lit = lbeg; lit != lend; ++lit)
|
||||||
snippets.insert(tclass[*cit].babelpreamble(
|
snippets.insert(tclass[*cit].babelpreamble(
|
||||||
*lit,
|
*lit,
|
||||||
buffer().language(),
|
buffer().params().encoding(),
|
||||||
use_polyglossia));
|
use_polyglossia));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1230,7 +1231,8 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
|
|||||||
if (flname != name)
|
if (flname != name)
|
||||||
snippets.insert(getFloatI18nPreamble(
|
snippets.insert(getFloatI18nPreamble(
|
||||||
type, name, buffer().language(),
|
type, name, buffer().language(),
|
||||||
buffer().language(), use_polyglossia));
|
buffer().params().encoding(),
|
||||||
|
use_polyglossia));
|
||||||
for (lang_it lit = lbeg; lit != lend; ++lit) {
|
for (lang_it lit = lbeg; lit != lend; ++lit) {
|
||||||
string const code = (*lit)->code();
|
string const code = (*lit)->code();
|
||||||
name = (*lit)->translateLayout(fl.name());
|
name = (*lit)->translateLayout(fl.name());
|
||||||
@ -1244,7 +1246,7 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po
|
|||||||
if (have_translation)
|
if (have_translation)
|
||||||
snippets.insert(getFloatI18nPreamble(
|
snippets.insert(getFloatI18nPreamble(
|
||||||
type, name, *lit,
|
type, name, *lit,
|
||||||
buffer().language(),
|
buffer().params().encoding(),
|
||||||
use_polyglossia));
|
use_polyglossia));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ void Layout::readSpacing(Lexer & lex)
|
|||||||
|
|
||||||
namespace {
|
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)
|
docstring const & templ, bool const polyglossia)
|
||||||
{
|
{
|
||||||
if (templ.empty())
|
if (templ.empty())
|
||||||
@ -875,9 +875,9 @@ docstring const i18npreamble(Language const * lang, Language const * buflang,
|
|||||||
// tex2lyx does not have getMessages()
|
// tex2lyx does not have getMessages()
|
||||||
LASSERT(false, /**/);
|
LASSERT(false, /**/);
|
||||||
#else
|
#else
|
||||||
string const enc = lang->encoding()->iconvName();
|
string const langenc = lang->encoding()->iconvName();
|
||||||
string const texenc = lang->encoding()->latexName();
|
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)
|
// First and second character of plane 15 (Private Use Area)
|
||||||
char const s1[5] = {0xf3, 0xb0, 0x80, 0x80, 0x00}; // U+F0000
|
char const s1[5] = {0xf3, 0xb0, 0x80, 0x80, 0x00}; // U+F0000
|
||||||
char const s2[5] = {0xf3, 0xb0, 0x80, 0x81, 0x00}; // U+F0001
|
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)) {
|
while (regex_search(preamble, sub, reg)) {
|
||||||
string const key = sub.str(1);
|
string const key = sub.str(1);
|
||||||
string translated = to_utf8(lang->translateLayout(key));
|
string translated = to_utf8(lang->translateLayout(key));
|
||||||
if (enc != bufenc)
|
if (langenc != bufenc)
|
||||||
translated = "\\inputencoding{" + texenc + "}"
|
translated = "\\inputencoding{" + texenc + "}"
|
||||||
+ string(s1) + enc + string(s2) + translated
|
+ string(s1) + langenc + string(s2) + translated
|
||||||
+ string(s1) + bufenc + string(s2);
|
+ string(s1) + bufenc + string(s2);
|
||||||
preamble = subst(preamble, sub.str(), translated);
|
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,
|
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
|
#ifndef LAYOUT_H
|
||||||
#define LAYOUT_H
|
#define LAYOUT_H
|
||||||
|
|
||||||
|
#include "Encoding.h"
|
||||||
#include "FontInfo.h"
|
#include "FontInfo.h"
|
||||||
#include "LayoutEnums.h"
|
#include "LayoutEnums.h"
|
||||||
#include "Spacing.h"
|
#include "Spacing.h"
|
||||||
@ -95,10 +96,10 @@ public:
|
|||||||
docstring const & preamble() const { return preamble_; }
|
docstring const & preamble() const { return preamble_; }
|
||||||
/// Get language dependent macro definitions needed for this layout
|
/// Get language dependent macro definitions needed for this layout
|
||||||
/// for language \p lang
|
/// 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
|
/// Get language and babel dependent macro definitions needed for
|
||||||
/// this layout for language \p lang
|
/// 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_; }
|
std::set<std::string> const & requires() const { return requires_; }
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user