}
+// FIXME This should really be controlled by the TOC level, or
+// something of the sort.
namespace {
const char * counters_to_save[] = {"section", "chapter"};
unsigned int const numcnts = sizeof(counters_to_save)/sizeof(char *);
}
-void InsetMathHull::addToToc(DocIterator const & pit) const
+void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
{
if (!buffer_) {
//FIXME: buffer_ should be set at creation for this inset! Problem is
if (!numbered_[row])
continue;
if (label_[row])
- label_[row]->addToToc(pit);
- toc.push_back(TocItem(pit, 0, nicelabel(row)));
+ label_[row]->addToToc(pit, output_active);
+ toc.push_back(TocItem(pit, 0, nicelabel(row), output_active));
}
}
{
if (type_ == hullEqnArray)
return "rcl"[col];
+ if (type_ == hullMultline)
+ return 'c';
if (type_ == hullGather)
return 'c';
if (type_ >= hullAlign)
}
+char InsetMathHull::displayColAlign(col_type col, row_type row) const
+{
+ if (type_ == hullMultline) {
+ if (row == 0)
+ return 'l';
+ if (row == nrows() - 1)
+ return 'r';
+ }
+ return InsetMathGrid::displayColAlign(col, row);
+}
+
+
int InsetMathHull::defaultColSpace(col_type col)
{
if (type_ == hullAlign || type_ == hullAlignAt)
docstring InsetMathHull::label(row_type row) const
{
- LASSERT(row < nrows(), /**/);
+ LASSERT(row < nrows(), return docstring());
if (InsetLabel * il = label_[row])
return il->screenLabel();
return docstring();
// it would be better to do this elsewhere, but we can't validate in
// InsetMathMatrix and we have no way, outside MathExtern, to know if
// we even have any matrices.
- features.addPreambleSnippet("<style type=\"text/css\">\n"
+ features.addCSSSnippet(
"table.matrix{display: inline-block; vertical-align: middle; text-align:center;}\n"
"table.matrix td{padding: 0.25px;}\n"
"td.ldelim{width: 0.5ex; border: thin solid black; border-right: none;}\n"
- "td.rdelim{width: 0.5ex; border: thin solid black; border-left: none;}\n"
- "</style>");
+ "td.rdelim{width: 0.5ex; border: thin solid black; border-left: none;}");
}
InsetMathGrid::validate(features);
}
void InsetMathHull::splitTo2Cols()
{
- LASSERT(ncols() == 1, /**/);
+ LASSERT(ncols() == 1, return);
InsetMathGrid::addCol(1);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 2 * row;
void InsetMathHull::splitTo3Cols()
{
- LASSERT(ncols() < 3, /**/);
+ LASSERT(ncols() < 3, return);
if (ncols() < 2)
splitTo2Cols();
InsetMathGrid::addCol(2);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 3 * row + 1;
- if (cell(i).size()) {
+ if (!cell(i).empty()) {
cell(i + 1) = MathData(buffer_, cell(i).begin() + 1, cell(i).end());
cell(i).erase(1, cell(i).size());
}
void InsetMathHull::write(WriteStream & os) const
{
- ModeSpecifier specifier(os, MATH_MODE);
+ ModeSpecifier specifier(os,
+ type_ == hullRegexp ? TEXT_MODE : MATH_MODE);
header_write(os);
InsetMathGrid::write(os);
footer_write(os);
void InsetMathHull::check() const
{
- LASSERT(numbered_.size() == nrows(), /**/);
- LASSERT(numbers_.size() == nrows(), /**/);
- LASSERT(label_.size() == nrows(), /**/);
+ LATTEST(numbered_.size() == nrows());
+ LATTEST(numbers_.size() == nrows());
+ LATTEST(label_.size() == nrows());
}
MathData ar;
if (cur.inMathed() && cur.selection()) {
asArray(grabAndEraseSelection(cur), ar);
- } else if (pos == cur.cell().size()) {
+ } else if (!pos == cur.cell().empty()) {
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
} else {
cur.undispatched();
break;
- case LFUN_BREAK_PARAGRAPH:
+ case LFUN_PARAGRAPH_BREAK:
// just swallow this
break;
if (type_ == hullSimple || type_ == hullEquation) {
cur.recordUndoInset();
bool const align =
- cur.bv().buffer().params().use_amsmath == BufferParams::package_on;
+ cur.bv().buffer().params().use_package("amsmath") == BufferParams::package_on;
mutate(align ? hullAlign : hullEqnArray);
// mutate() may change labels and such.
cur.forceBufferUpdate();
// we never allow this in math, and we want to bind enter
// to another actions in command-alternatives
- case LFUN_BREAK_PARAGRAPH:
+ case LFUN_PARAGRAPH_BREAK:
status.setEnabled(false);
return true;
case LFUN_MATH_MUTATE: {
}
-int InsetMathHull::plaintext(odocstream & os, OutputParams const &) const
+int InsetMathHull::plaintext(odocstringstream & os,
+ OutputParams const & op, size_t max_length) const
{
// disables ASCII-art for export of equations. See #2275.
if (0 && display()) {
// reset metrics cache to "real" values
//metrics();
return tpain.textheight();
- } else {
- odocstringstream oss;
- Encoding const * const enc = encodings.fromLyXName("utf8");
- WriteStream wi(oss, false, true, WriteStream::wsDefault, enc);
- // Fix Bug #6139
- if (type_ == hullRegexp)
- write(wi);
- else {
- for (row_type r = 0; r < nrows(); ++r) {
- for (col_type c = 0; c < ncols(); ++c)
- wi << (c == 0 ? "" : "\t") << cell(index(r, c));
- wi << "\n";
- }
+ }
+
+ odocstringstream oss;
+ Encoding const * const enc = encodings.fromLyXName("utf8");
+ WriteStream wi(oss, false, true, WriteStream::wsDefault, enc);
+
+ // Fix Bug #6139
+ if (type_ == hullRegexp)
+ write(wi);
+ else {
+ for (row_type r = 0; r < nrows(); ++r) {
+ for (col_type c = 0; c < ncols(); ++c)
+ wi << (c == 0 ? "" : "\t") << cell(index(r, c));
+ // if it's for the TOC, we write just the first line
+ // and do not include the newline.
+ if (op.for_toc || op.for_tooltip || oss.str().size() >= max_length)
+ break;
+ wi << "\n";
}
- docstring const str = oss.str();
- os << str;
- return str.size();
}
+ docstring const str = oss.str();
+ os << str;
+ return str.size();
}
docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
{
BufferParams::MathOutput const mathtype =
- buffer().params().html_math_output;
+ buffer().masterBuffer()->params().html_math_output;
bool success = false;
void InsetMathHull::toString(odocstream & os) const
{
- plaintext(os, OutputParams(0));
+ odocstringstream ods;
+ plaintext(ods, OutputParams(0));
+ os << ods.str();
}
void InsetMathHull::forToc(docstring & os, size_t) const
{
odocstringstream ods;
- plaintext(ods, OutputParams(0));
+ OutputParams op(0);
+ op.for_toc = true;
+ plaintext(ods, op);
os += ods.str();
}
-docstring InsetMathHull::contextMenuName() const
+string InsetMathHull::contextMenuName() const
{
- return from_ascii("context-math");
+ return "context-math";
}