]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathBig.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathBig.cpp
index e56acca0785c713ac60d8d2c1bc18ce7537ef2a2..a707ab10e416147a8a57b35018173cc9fc39e011 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
 #include <config.h>
 
 #include "InsetMathBig.h"
+
 #include "MathSupport.h"
 #include "MathStream.h"
-#include "MathStream.h"
+#include "MetricsInfo.h"
 
 #include "frontends/FontMetrics.h"
 
+#include "support/docstream.h"
 #include "support/lstrings.h"
 
 
 namespace lyx {
 
-using std::auto_ptr;
-
 
 InsetMathBig::InsetMathBig(docstring const & name, docstring const & delim)
        : name_(name), delim_(delim)
@@ -36,9 +36,9 @@ docstring InsetMathBig::name() const
 }
 
 
-auto_ptr<InsetBase> InsetMathBig::doClone() const
+Inset * InsetMathBig::clone() const
 {
-       return auto_ptr<InsetBase>(new InsetMathBig(*this));
+       return new InsetMathBig(*this);
 }
 
 
@@ -62,36 +62,34 @@ double InsetMathBig::increase() const
 }
 
 
-bool InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        double const h = theFontMetrics(mi.base.font).ascent('I');
        double const f = increase();
        dim.wid = 6;
        dim.asc = int(h + f * h);
        dim.des = int(f * h);
-       if (dim_ == dim)
-               return false;
-       dim_ = dim;
-       return true;
 }
 
 
 void InsetMathBig::draw(PainterInfo & pi, int x, int y) const
 {
+       Dimension const dim = dimension(*pi.base.bv);
        // mathed_draw_deco does not use the leading backslash, so remove it
        // (but don't use ltrim if this is the backslash delimiter).
        // Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco
        // would treat it as |.
        docstring const delim = (delim_ == "\\|") ?  from_ascii("Vert") :
                (delim_ == "\\\\") ? from_ascii("\\") : support::ltrim(delim_, "\\");
-       mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(),
-                        delim);
+       mathed_draw_deco(pi, x + 1, y - dim.ascent(), 4, dim.height(),
+                        delim);
        setPosCache(pi, x, y);
 }
 
 
 void InsetMathBig::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        os << '\\' << name_ << delim_;
        if (delim_[0] == '\\')
                os.pendingSpace(true);