#include "InsetMathGrid.h"
#include "MathData.h"
-#include "MathMLStream.h"
#include "MathStream.h"
#include "BufferView.h"
namespace {
-string verboseHLine(int n)
+docstring verboseHLine(int n)
{
- string res;
+ docstring res;
for (int i = 0; i < n; ++i)
res += "\\hline";
if (n)
//////////////////////////////////////////////////////////////
-InsetMathGrid::InsetMathGrid(char v, string const & h)
+InsetMathGrid::InsetMathGrid(char v, docstring const & h)
: InsetMathNest(guessColumns(h)),
rowinfo_(2),
colinfo_(guessColumns(h) + 1),
}
-InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, string const & h)
+InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, docstring const & h)
: InsetMathNest(m * n),
rowinfo_(n + 1),
colinfo_(m + 1),
}
-void InsetMathGrid::halign(string const & hh)
+void InsetMathGrid::halign(docstring const & hh)
{
col_type col = 0;
- for (string::const_iterator it = hh.begin(); it != hh.end(); ++it) {
- char c = *it;
+ for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it) {
+ char_type c = *it;
if (c == '|') {
colinfo_[col].lines_++;
} else if (col >= ncols()) {
// Only '|' is allowed in the last dummy column
break;
} else if (c == 'c' || c == 'l' || c == 'r') {
- colinfo_[col].align_ = c;
+ colinfo_[col].align_ = (char)c;
++col;
colinfo_[col].lines_ = 0;
} else {
}
-InsetMathGrid::col_type InsetMathGrid::guessColumns(string const & hh) const
+InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh) const
{
col_type col = 0;
- for (string::const_iterator it = hh.begin(); it != hh.end(); ++it)
+ for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it)
if (*it == 'c' || *it == 'l' || *it == 'r')
++col;
// let's have at least one column, even if we did not recognize its
}
-string InsetMathGrid::halign() const
+docstring InsetMathGrid::halign() const
{
- string res;
+ docstring res;
for (col_type col = 0; col < ncols(); ++col) {
- res += string(colinfo_[col].lines_, '|');
+ res += docstring(colinfo_[col].lines_, '|');
res += colinfo_[col].align_;
}
- return res + string(colinfo_[ncols()].lines_, '|');
+ return res + docstring(colinfo_[ncols()].lines_, '|');
}
}
-string InsetMathGrid::eolString(row_type row, bool emptyline, bool fragile) const
+docstring InsetMathGrid::eolString(row_type row, bool emptyline, bool fragile) const
{
- string eol;
+ docstring eol;
if (!rowinfo_[row].crskip_.zero())
- eol += '[' + rowinfo_[row].crskip_.asLatexString() + ']';
+ eol += '[' + from_utf8(rowinfo_[row].crskip_.asLatexString()) + ']';
// make sure an upcoming '[' does not break anything
if (row + 1 < nrows()) {
// only add \\ if necessary
if (eol.empty() && row + 1 == nrows() && (nrows() == 1 || !emptyline))
- return string();
+ return docstring();
return (fragile ? "\\protect\\\\" : "\\\\") + eol;
}
-string InsetMathGrid::eocString(col_type col, col_type lastcol) const
+docstring InsetMathGrid::eocString(col_type col, col_type lastcol) const
{
if (col + 1 == lastcol)
- return string();
- return " & ";
+ return docstring();
+ return from_ascii(" & ");
}
}
-void InsetMathGrid::mathmlize(MathMLStream & os) const
+void InsetMathGrid::mathmlize(MathStream & os) const
{
os << MTag("mtable");
for (row_type row = 0; row < nrows(); ++row) {
void InsetMathGrid::write(WriteStream & os) const
{
- string eol;
+ docstring eol;
for (row_type row = 0; row < nrows(); ++row) {
os << verboseHLine(rowinfo_[row].lines_);
// don't write & and empty cells at end of line
if (!emptyline && row + 1 < nrows())
os << "\n";
}
- string const s = verboseHLine(rowinfo_[nrows()].lines_);
+ docstring const s = verboseHLine(rowinfo_[nrows()].lines_);
if (!s.empty()) {
if (eol.empty()) {
if (os.fragile())