From: Günter Milde Date: Mon, 18 Mar 2019 11:49:10 +0000 (+0100) Subject: Warn user, if input encodings of master and child document differ. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ebcf808c26766ab0c30ad54bc300554153fa8b1b;p=features.git Warn user, if input encodings of master and child document differ. --- diff --git a/autotests/export/latex/parent-with-other-inputenc.lyx b/autotests/export/latex/parent-with-other-inputenc.lyx index d630a7f18b..b347d0344a 100644 --- a/autotests/export/latex/parent-with-other-inputenc.lyx +++ b/autotests/export/latex/parent-with-other-inputenc.lyx @@ -142,7 +142,7 @@ the parent loads the child document with wrong input encoding. \begin_layout Standard Example: This document uses \family typewriter -latin9 +iso8859-15 \family default , the included child \family typewriter diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 988a051a78..87a817337b 100755 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -792,6 +792,17 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const from_utf8(child_tf), from_utf8(master_tf)); Alert::warning(_("Different use-non-TeX-fonts settings"), text, true); + } + else if (tmp->params().inputenc != masterBuffer->params().inputenc) { + docstring text = bformat(_("Included file `%1$s'\n" + "uses input encoding \"%2$s\" [%3$s]\n" + "while parent file uses input encoding \"%4$s\" [%5$s]."), + included_file.displayName(), + _(tmp->params().inputenc), + from_utf8(tmp->params().encoding().guiName()), + _(masterBuffer->params().inputenc), + from_utf8(masterBuffer->params().encoding().guiName())); + Alert::warning(_("Different LaTeX input encodings"), text, true); } // Make sure modules used in child are all included in master diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index 21fe05aa09..e69fc8837b 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -1575,5 +1575,22 @@ docstring bformat(docstring const & fmt, return subst(str, from_ascii("%%"), from_ascii("%")); } +docstring bformat(docstring const & fmt, docstring const & arg1, + docstring const & arg2, docstring const & arg3, + docstring const & arg4, docstring const & arg5) +{ + LATTEST(contains(fmt, from_ascii("%1$s"))); + LATTEST(contains(fmt, from_ascii("%2$s"))); + LATTEST(contains(fmt, from_ascii("%3$s"))); + LATTEST(contains(fmt, from_ascii("%4$s"))); + LATTEST(contains(fmt, from_ascii("%5$s"))); + docstring str = subst(fmt, from_ascii("%1$s"), arg1); + str = subst(str, from_ascii("%2$s"), arg2); + str = subst(str, from_ascii("%3$s"), arg3); + str = subst(str, from_ascii("%4$s"), arg4); + str = subst(str, from_ascii("%5$s"), arg5); + return subst(str, from_ascii("%%"), from_ascii("%")); +} + } // namespace support } // namespace lyx diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 7d2fc6dd77..fcf1cbb6fe 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -372,6 +372,7 @@ docstring bformat(docstring const & fmt, char const * arg1, docstring const & ar docstring bformat(docstring const & fmt, int arg1, int arg2); docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3); docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3, docstring const & arg4); +docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3, docstring const & arg4, docstring const & arg5); } // namespace support