]> git.lyx.org Git - lyx.git/blobdiff - src/BufferEncodings.cpp
tex2lyx: fix import of umlauts and ß in math (#12739)
[lyx.git] / src / BufferEncodings.cpp
index 87000ac9c82402e7f24443f580926dc6c2340bf1..fe7e90c230b6299ad36fcdd982ef22f2d1d5c5f4 100644 (file)
@@ -35,21 +35,15 @@ void BufferEncodings::initUnicodeMath(Buffer const & buffer, bool for_master)
        }
 
        // Check this buffer
-       Inset & inset = buffer.inset();
-       InsetIterator it = inset_iterator_begin(inset);
-       InsetIterator const end = inset_iterator_end(inset);
-       for (; it != end; ++it)
-               it->initUnicodeMath();
+       for (Inset const & it : buffer.inset())
+               it.initUnicodeMath();
 
        if (!for_master)
                return;
 
        // Check children
-       ListOfBuffers blist = buffer.getDescendents();
-       ListOfBuffers::const_iterator bit = blist.begin();
-       ListOfBuffers::const_iterator const bend = blist.end();
-       for (; bit != bend; ++bit)
-               initUnicodeMath(**bit, false);
+       for (Buffer * buf : buffer.getDescendants())
+               initUnicodeMath(*buf, false);
 }
 
 
@@ -58,7 +52,7 @@ void BufferEncodings::validate(char_type c, LaTeXFeatures & features, bool for_m
        CharInfo const & ci = Encodings::unicodeCharInfo(c);
        if (ci.isUnicodeSymbol()) {
                // In mathed, c could be used both in textmode and mathmode
-               docstring const textcommand = ci.textcommand();
+               docstring const textcommand = ci.textCommand();
                bool const math_mode = for_mathed && isMathCmd(c);
                bool const use_math = math_mode ||
                                      (!for_mathed && textcommand.empty());
@@ -71,9 +65,9 @@ void BufferEncodings::validate(char_type c, LaTeXFeatures & features, bool for_m
                // and if we do not use unicode-math
                if ((math_mode && !unicode_math)
                     || (use_math && !plain_utf8)) {
-                       string const mathpreamble = ci.mathpreamble();
+                       string const mathpreamble = ci.mathPreamble();
                        if (!mathpreamble.empty()) {
-                               if (ci.mathfeature()) {
+                               if (ci.mathFeature()) {
                                        string feats = mathpreamble;
                                        while (!feats.empty()) {
                                                string feat;
@@ -81,22 +75,25 @@ void BufferEncodings::validate(char_type c, LaTeXFeatures & features, bool for_m
                                                features.require(feat);
                                        }
                                } else
-                                       features.addPreambleSnippet(mathpreamble);
+                                       features.addPreambleSnippet(from_utf8(mathpreamble));
                        }
                }
                // with utf8-plain, we do not load packages (see #7766)
                if (use_text && !plain_utf8) {
-                       string const textpreamble = ci.textpreamble();
+                       string const textpreamble = ci.textPreamble();
                        if (!textpreamble.empty()) {
-                               if (ci.textfeature()) {
+                               if (ci.textFeature()) {
                                        string feats = textpreamble;
                                        while (!feats.empty()) {
                                                string feat;
                                                feats = split(feats, feat, ',');
-                                               features.require(feat);
+                                               // context-dependent features are handled
+                                               // in Paragraph::Private::validate()
+                                               if (!contains(feat, '='))
+                                                       features.require(feat);
                                        }
                                } else
-                                       features.addPreambleSnippet(textpreamble);
+                                       features.addPreambleSnippet(from_utf8(textpreamble));
                        }
                }
        }