]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathXYArrow.cpp
Please Coverity (code should be equivalent)
[lyx.git] / src / mathed / InsetMathXYArrow.cpp
index 884e78423bb9153659be15f8a06c1bfac944ea05..80aeb7276b5435d9a9119ef808992280b4be32dd 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 "MathStream.h"
 #include "MathSupport.h"
 #include "frontends/Painter.h"
-#include "debug.h"
+#include "support/debug.h"
 
+using namespace std;
 
 namespace lyx {
 
 
-using std::max;
-
-
 InsetMathXYArrow::InsetMathXYArrow()
-       : InsetMathNest(2)
+       : InsetMathNest(2), up_(false), target_(0)
 {}
 
 
@@ -91,9 +89,9 @@ bool InsetMathXYArrow::metrics(MetricsInfo & mi) const
 
        if (editing()) {
                int w    = mathed_string_width(mi.base.font, from_ascii("target: "));
-               width_   = w + max(cell(0).width(), cell(1).width());
-               ascent_  = cell(0).ascent();
-               descent_ = cell(0).descent() + cell(1).height() + 10;
+               width_   = w + max(dim0.width(), dim1.wid);
+               ascent_  = dim0.asc;
+               descent_ = dim0.des + dim1.height() + 10;
        } else {
                width_   = 0;
                ascent_  = 0;
@@ -120,9 +118,9 @@ void InsetMathXYArrow::draw(PainterInfo & pi, int x, int y) const
 
                cell(0).draw(pi, x + lwid, y);
                pi.base.text(x + 3, y, "target");
-               y += max(cell(0).descent(), ldes) + 5;
+               y += max(dim0.des, ldes) + 5;
 
-               y += max(cell(1).ascent(), lasc) + 5;
+               y += max(dim1.asc, lasc) + 5;
                cell(1).draw(pi, x + lwid, y);
                pi.base.text(x + 3, y, "label");
 
@@ -133,7 +131,7 @@ void InsetMathXYArrow::draw(PainterInfo & pi, int x, int y) const
                pi.pain.text(x, y, "X");
                MathData const & s = sourceCell();
                MathData const & t = targetCell();
-               pi.pain.line(s.xm(), s.ym(), t.xm(), t.ym(), Color::math);
+               pi.pain.line(s.xm(), s.ym(), t.xm(), t.ym(), Color_math);
                cell(1).draw(pi, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2);
 
        }
@@ -142,10 +140,11 @@ void InsetMathXYArrow::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathXYArrow::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        os << "\\ar";
-       if (cell(0).size())
+       if (!cell(0).empty())
                os << '[' << cell(0) << ']';
-       if (cell(1).size())
+       if (!cell(1).empty())
                os << (up_ ? '^' : '_') << '{' << cell(1) << '}';
        os << " ";
 }
@@ -159,4 +158,15 @@ void InsetMathXYArrow::normalize(NormalStream & os) const
 }
 
 
+void InsetMathXYArrow::mathmlize(MathStream &) const
+{
+       throw MathExportException();
+}
+
+
+void InsetMathXYArrow::htmlize(HtmlStream &) const 
+{
+       throw MathExportException(); 
+}
+
 } // namespace lyx