]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathData.cpp
We only support gcc >= 4.9.
[lyx.git] / src / mathed / MathData.cpp
index ce1f4b5edc331a9c4dc04506b239b774100e50aa..d3ce3a31c877ec03843005424a0351b3d044ac7d 100644 (file)
 
 #include "InsetMathBrace.h"
 #include "InsetMathFont.h"
+#include "InsetMathMacro.h"
 #include "InsetMathScript.h"
 #include "MacroTable.h"
-#include "InsetMathMacro.h"
+#include "MathRow.h"
 #include "MathStream.h"
 #include "MathSupport.h"
 #include "MetricsInfo.h"
@@ -27,6 +28,7 @@
 #include "BufferView.h"
 #include "CoordCache.h"
 #include "Cursor.h"
+#include "Dimension.h"
 
 #include "mathed/InsetMathUnknown.h"
 
@@ -37,7 +39,6 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
-#include "support/lyxalgo.h"
 
 #include <cstdlib>
 
@@ -47,8 +48,7 @@ namespace lyx {
 
 
 MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
-       : base_type(from, to), minasc_(0), mindes_(0), slevel_(0),
-         sshift_(0), buffer_(buf)
+       : base_type(from, to), buffer_(buf)
 {}
 
 
@@ -224,6 +224,7 @@ bool MathData::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
 {
        bool has_contents = false;
        BufferView * bv = mi.base.bv;
+       display_style_ = mi.base.font.style() == DISPLAY_STYLE;
        MathData * ar = const_cast<MathData*>(this);
        ar->updateMacros(&bv->cursor(), mi.macrocontext,
                         InternalUpdate, mi.base.macro_nesting);
@@ -403,8 +404,8 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
 {
        // If we are editing a macro, we cannot update it immediately,
        // otherwise wrong undo steps will be recorded (bug 6208).
-       InsetMath const * inmath = cur ? cur->inset().asInsetMath() : nullptr;
-       InsetMathMacro const * inmacro = inmath ? inmath->asMacro() : nullptr;
+       InsetMath const * inmath = cur ? cur->inset().asInsetMath() : 0;
+       InsetMathMacro const * inmacro = inmath ? inmath->asMacro() : 0;
        docstring const edited_name = inmacro ? inmacro->name() : docstring();
 
        // go over the array and look for macros
@@ -968,6 +969,17 @@ MathClass MathData::mathClass() const
 }
 
 
+MathClass MathData::firstMathClass() const
+{
+       for (MathAtom const & at : *this) {
+               MathClass mc = at->mathClass();
+               if (mc != MC_UNKNOWN)
+                       return mc;
+       }
+       return MC_ORD;
+}
+
+
 MathClass MathData::lastMathClass() const
 {
        MathClass res = MC_ORD;