From 487e9ad92aa604490cbaae148a281fccc90dc0bd Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Fri, 12 Mar 2010 18:36:19 +0000 Subject: [PATCH] Fix bug #6377: Tex2lyx error with multiple languages. We have to set the language again when a new paragraph is started. Otherwise the n'th paragraph in a certain language is set to the document language. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33727 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/Context.cpp | 5 ++++- src/tex2lyx/Context.h | 2 ++ src/tex2lyx/text.cpp | 10 +++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/tex2lyx/Context.cpp b/src/tex2lyx/Context.cpp index 33050489a0..2db797d67d 100644 --- a/src/tex2lyx/Context.cpp +++ b/src/tex2lyx/Context.cpp @@ -50,7 +50,8 @@ bool operator==(TeXFont const & f1, TeXFont const & f2) f1.size == f2.size && f1.family == f2.family && f1.series == f2.series && - f1.shape == f2.shape; + f1.shape == f2.shape && + f1.language == f2.language; } @@ -65,6 +66,8 @@ void output_font_change(ostream & os, TeXFont const & oldfont, os << "\n\\shape " << newfont.shape << '\n'; if (oldfont.size != newfont.size) os << "\n\\size " << newfont.size << '\n'; + if (oldfont.language != newfont.language) + os << "\n\\lang " << newfont.language << '\n'; } diff --git a/src/tex2lyx/Context.h b/src/tex2lyx/Context.h index c5c45b06fb..ccd9c0541b 100644 --- a/src/tex2lyx/Context.h +++ b/src/tex2lyx/Context.h @@ -40,11 +40,13 @@ public: family = "default"; series = "default"; shape = "default"; + language = "default"; } std::string size; std::string family; std::string series; std::string shape; + std::string language; }; diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 188152078b..b70e1e4686 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1121,8 +1121,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, Context & context) { Layout const * newlayout = 0; - // store the current selectlanguage to be used after \foreignlanguage - string selectlang; // Store the latest bibliographystyle (needed for bibtex inset) string bibliographystyle; bool const use_natbib = used_packages.find("natbib") != used_packages.end(); @@ -2215,10 +2213,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // save the language for the case that a // \foreignlanguage is used - //FIXME: this is wrong, the language should - // be saved in the context. (JMarc) - selectlang = subst(p.verbatim_item(), "\n", " "); - os << "\\lang " << selectlang << "\n"; + context.font.language = subst(p.verbatim_item(), "\n", " "); + os << "\\lang " << context.font.language << "\n"; } else if (t.cs() == "foreignlanguage") { @@ -2229,7 +2225,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // has to be parsed (like for \textsf, for // example). // set back to last selectlanguage - os << "\n\\lang " << selectlang << "\n"; + os << "\n\\lang " << context.font.language << "\n"; } else if (t.cs() == "inputencoding") {