X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathTabular.cpp;h=e4123a565509cd6dd0b96875a42084a0e102104d;hb=1f352b390c897d583bffaad695c04b613b88a139;hp=8d59cbd1df4e6bf241e8374bd082825ae2932f9e;hpb=90837aaf6eee523fd594c0ea7f44c053bb49a3cf;p=lyx.git diff --git a/src/mathed/InsetMathTabular.cpp b/src/mathed/InsetMathTabular.cpp index 8d59cbd1df..e4123a5655 100644 --- a/src/mathed/InsetMathTabular.cpp +++ b/src/mathed/InsetMathTabular.cpp @@ -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. */ @@ -16,20 +16,23 @@ #include "MathStream.h" #include "MathStream.h" +#include "MetricsInfo.h" + #include "support/lstrings.h" #include namespace lyx { -InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n) - : InsetMathGrid(m, n), name_(name) +InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m, + int n) + : InsetMathGrid(buf, m, n), name_(name) {} -InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n, - char valign, docstring const & halign) - : InsetMathGrid(m, n, valign, halign), name_(name) +InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m, + int n, char valign, docstring const & halign) + : InsetMathGrid(buf, m, n, valign, halign), name_(name) {} @@ -42,41 +45,26 @@ Inset * InsetMathTabular::clone() const void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const { - FontSetChanger dummy(mi.base, "textnormal"); + Changer dummy = mi.base.changeFontSet("textnormal"); InsetMathGrid::metrics(mi, dim); - dim.wid += 6; -} - - -Dimension const InsetMathTabular::dimension(BufferView const & bv) const -{ - Dimension dim = InsetMathGrid::dimension(bv); - dim.wid += 6; - return dim; } void InsetMathTabular::draw(PainterInfo & pi, int x, int y) const { - FontSetChanger dummy(pi.base, "textnormal"); - InsetMathGrid::drawWithMargin(pi, x, y, 4, 2); + Changer dummy = pi.base.changeFontSet("textnormal"); + InsetMathGrid::draw(pi, x, y); } void InsetMathTabular::write(WriteStream & os) const { - // This is a text mode tabular, so close any previous \ensuremath - // command and set the proper mode. - if (os.latex() && os.pendingBrace()) { - os.pendingBrace(false); - os << '}'; - } - bool textmode = os.textMode(); - os.textMode(true); + ModeSpecifier specifier(os, TEXT_MODE); if (os.fragile()) os << "\\protect"; os << "\\begin{" << name_ << '}'; + bool open = os.startOuterRow(); char const v = verticalAlignment(); if (v == 't' || v == 'b') @@ -88,10 +76,10 @@ void InsetMathTabular::write(WriteStream & os) const if (os.fragile()) os << "\\protect"; os << "\\end{" << name_ << '}'; + if (open) + os.startOuterRow(); // adding a \n here is bad if the tabular is the last item // in an \eqnarray... - - os.textMode(textmode); }