]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
... and RELEASE-NOTES
[lyx.git] / src / mathed / MathMacro.cpp
index cb853a3ba952ee6604ca0c05dae1ddcd40a3f5ad..06a55bf7036d391756f80417f045d6e57e52d092 100644 (file)
@@ -614,9 +614,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                drawMarkers2(pi, expx, expy);
        } else {
                bool drawBox = lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX;
-               bool user_macro = mathedWordList().find(name()) == mathedWordList().end();
-               bool upshape = user_macro ? false : d->macro_ && d->macro_->symbol()
-                               && d->macro_->symbol()->extra == "textmode";
+               bool upshape = currentMode() == TEXT_MODE;
                Changer dummy = pi.base.font.changeShape(upshape ? UP_SHAPE
                                                        : pi.base.font.shape());
 
@@ -753,6 +751,17 @@ size_t MathMacro::appetite() const
 }
 
 
+InsetMath::mode_type MathMacro::currentMode() const
+{
+       // User defined macros are always assumed to be mathmode macros.
+       // Only the global macros defined in lib/symbols may be textmode.
+
+       MacroData const * data = MacroTable::globalMacros().get(name());
+       bool textmode = data && data->symbol() && data->symbol()->extra == "textmode";
+       return textmode ? TEXT_MODE : MATH_MODE;
+}
+
+
 void MathMacro::validate(LaTeXFeatures & features) const
 {
        // Immediately after a document is loaded, in some cases the MacroData
@@ -930,11 +939,11 @@ bool MathMacro::folded() const
 
 void MathMacro::write(WriteStream & os) const
 {
-       bool user_macro = mathedWordList().find(name()) == mathedWordList().end();
-       bool textmode_macro = user_macro ? false : d->macro_ && d->macro_->symbol()
-                               && d->macro_->symbol()->extra == "textmode";
-       bool needs_mathmode = user_macro ? bool(d->macro_) : d->macro_ && (!d->macro_->symbol()
-                               || d->macro_->symbol()->extra != "textmode");
+       MacroData const * data = MacroTable::globalMacros().get(name());
+       bool textmode_macro = data && data->symbol()
+                                  && data->symbol()->extra == "textmode";
+       bool needs_mathmode = data && (!data->symbol()
+                                      || data->symbol()->extra != "textmode");
 
        MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro);