From 7feb18698eb398be9b664670c2001d06adab6090 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 15 Aug 2002 17:41:24 +0000 Subject: [PATCH] re-use code... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5002 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_gridinset.C | 1 + src/mathed/math_gridinset.h | 4 ++-- src/mathed/math_hullinset.C | 29 ++++++++++++++--------------- src/mathed/math_hullinset.h | 4 ++++ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index b1108f6d12..7de23595a1 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -863,6 +863,7 @@ void MathGridInset::write(WriteStream & os) const { for (row_type row = 0; row < nrows(); ++row) { os << verboseHLine(rowinfo_[row].lines_); + // don't write & and empty cells at end of line for (col_type col = 0; col < ncols(); ++col) os << cell(index(row, col)) << eocString(col); os << eolString(row, os.fragile()); diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 79c8ad45fc..cef894035a 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -216,9 +216,9 @@ protected: /// returns y offset of cell compared to inset int cellYOffset(idx_type idx) const; /// returns proper 'end of line' code for LaTeX - string eolString(row_type row, bool fragile = false) const; + virtual string eolString(row_type row, bool fragile = false) const; /// returns proper 'end of column' code for LaTeX - string eocString(col_type col) const; + virtual string eocString(col_type col) const; /// extract number of columns from alignment string col_type guessColumns(string const & halign) const; /// splits cells and shifts right part to the next cell diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 8b1c556c5c..039eef924c 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -607,24 +607,23 @@ void MathHullInset::mutate(string const & newtype) } -void MathHullInset::write(WriteStream & os) const +string MathHullInset::eolString(row_type row, bool fragile) const { - header_write(os); - - bool n = numberedType(); - - for (row_type row = 0; row < nrows(); ++row) { - for (col_type col = 0; col < ncols(); ++col) - os << cell(index(row, col)) << eocString(col); - if (n) { - if (!label_[row].empty()) - os << "\\label{" << label_[row] << "}"; - if (nonum_[row]) - os << "\\nonumber "; - } - os << eolString(row); + string res; + if (numberedType()) { + if (!label_[row].empty()) + res += "\\label{" + label_[row] + "}"; + if (nonum_[row]) + res += "\\nonumber "; } + return res + MathGridInset::eolString(row, fragile); +} + +void MathHullInset::write(WriteStream & os) const +{ + header_write(os); + MathGridInset::write(os); footer_write(os); } diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index b45c4f8872..1c84e36ff6 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -89,6 +89,10 @@ public: /// void infoize(std::ostream & os) const; +protected: + /// + string eolString(row_type row, bool fragile) const; + private: /// void setType(string const & type); -- 2.39.2