]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathArray.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathArray.cpp
index 544d6a47d1846dc64fa600129477e2caffd70f04..a543a036f61de6aa9c6d9179bf10647db85a96bc 100644 (file)
@@ -3,34 +3,30 @@
  * 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 "LaTeXFeatures.h"
 #include "InsetMathArray.h"
+
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathParser.h"
 #include "MathStream.h"
+#include "MetricsInfo.h"
 
 #include "support/lstrings.h"
 
 #include <iterator>
 #include <sstream>
 
+using namespace std;
 
 namespace lyx {
 
-using std::getline;
-using std::auto_ptr;
-using std::istringstream;
-using std::istream_iterator;
-using std::vector;
-using std::string;
-
 
 InsetMathArray::InsetMathArray(docstring const & name, int m, int n)
        : InsetMathGrid(m, n), name_(name)
@@ -43,12 +39,6 @@ InsetMathArray::InsetMathArray(docstring const & name, int m, int n,
 {}
 
 
-InsetMathArray::InsetMathArray(docstring const & name, char valign,
-               docstring const & halign)
-       : InsetMathGrid(valign, halign), name_(name)
-{}
-
-
 InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
        : InsetMathGrid(1, 1), name_(name)
 {
@@ -73,20 +63,25 @@ InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
 }
 
 
-auto_ptr<Inset> InsetMathArray::doClone() const
+Inset * InsetMathArray::clone() const
 {
-       return auto_ptr<Inset>(new InsetMathArray(*this));
+       return new InsetMathArray(*this);
 }
 
 
-bool InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        ArrayChanger dummy(mi.base);
        InsetMathGrid::metrics(mi, dim);
        dim.wid += 6;
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
+}
+
+
+Dimension const InsetMathArray::dimension(BufferView const & bv) const
+{
+       Dimension dim = InsetMathGrid::dimension(bv);
+       dim.wid += 6;
+       return dim;
 }
 
 
@@ -100,13 +95,16 @@ void InsetMathArray::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathArray::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
+
        if (os.fragile())
                os << "\\protect";
        os << "\\begin{" << name_ << '}';
 
-       if (v_align_ == 't' || v_align_ == 'b')
-               os << '[' << char(v_align_) << ']';
-       os << '{' << halign() << "}\n";
+       char const v = verticalAlignment();
+       if (v == 't' || v == 'b')
+               os << '[' << v << ']';
+       os << '{' << horizontalAlignments() << "}\n";
 
        InsetMathGrid::write(os);