}
-InsetTableCell splitCell(InsetTableCell & head, docstring const align_d, bool & hassep)
+DocIterator separatorPos(InsetTableCell * cell, docstring const & align_d)
{
- InsetTableCell tail = InsetTableCell(head);
-
- DocIterator dit = doc_iterator_begin(&head.buffer(), &head);
+ DocIterator dit = doc_iterator_begin(&(cell->buffer()), cell);
for (; dit; dit.forwardChar())
- if (dit.inTexted() && dit.depth()==1
+ if (dit.inTexted() && dit.depth() == 1
&& dit.paragraph().find(align_d, false, false, dit.pos()))
break;
- pit_type const psize = head.paragraphs().front().size();
+ return dit;
+}
+
+
+InsetTableCell splitCell(InsetTableCell & head, docstring const align_d, bool & hassep)
+{
+ InsetTableCell tail = InsetTableCell(head);
+ DocIterator const dit = separatorPos(&head, align_d);
hassep = dit;
if (hassep) {
+ pit_type const psize = head.paragraphs().front().size();
head.paragraphs().front().eraseChars(dit.pos(), psize, false);
tail.paragraphs().front().eraseChars(0,
dit.pos() < psize ? dit.pos() + 1 : psize, false);
Tabular::idx_type Tabular::getFirstCellInRow(row_type row) const
{
col_type c = 0;
- while (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW)
+ idx_type const numcells = numberOfCellsInRow(row);
+ // we check against numcells to make sure we do not crash if all the
+ // cells are multirow (bug #7535), but in that case our return value
+ // is really invalid, i.e., it is NOT the first cell in the row. but
+ // i do not know what to do here. (rgh)
+ while (c < numcells - 1
+ && cell_info[row][c].multirow == CELL_PART_OF_MULTIROW)
++c;
return cell_info[row][c].cellno;
}
Tabular::idx_type Tabular::getLastCellInRow(row_type row) const
{
col_type c = ncols() - 1;
- while (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW
- || cell_info[row][c].multicolumn == CELL_PART_OF_MULTICOLUMN)
+ // of course we check against 0 so we don't crash. but we have the same
+ // problem as in the previous routine: if all the cells are part of a
+ // multirow or part of a multi column, then our return value is invalid.
+ while (c > 0
+ && (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW
+ || cell_info[row][c].multicolumn == CELL_PART_OF_MULTICOLUMN))
--c;
return cell_info[row][c].cellno;
}
}
-Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number)
+Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number,
+ bool const bottom_border)
{
idx_type const col = cellColumn(cell);
idx_type const row = cellRow(cell);
// cells: left
cs.alignment = LYX_ALIGN_LEFT;
- // set the bottom row of the last selected cell
- setBottomLine(cell, bottomLine(cell + (number - 1)*ncols()));
+ // set the bottom line of the last selected cell
+ setBottomLine(cell, bottom_border);
for (idx_type i = 1; i < number; ++i) {
CellData & cs1 = cell_info[row + i][col];
}
-int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
+void Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
{
// we only output complete row lines and the 1st row here, the rest
// is done in Tabular::TeXBottomHLine(...)
// multirow, no line must be drawn.
if (row != 0)
if (isMultiRow(cellIndex(row, c))
- && isMultiRow(cellIndex(row - 1, c)))
- topline[c] = false;
+ && cell_info[row][c].multirow != CELL_BEGIN_OF_MULTIROW)
+ topline[c] = false;
if (topline[c])
++nset;
}
// do nothing if empty first row, or incomplete row line after
if ((row == 0 && nset == 0) || (row > 0 && nset != ncols()))
- return 0;
+ return;
// only output complete row lines and the 1st row's clines
if (nset == ncols()) {
}
}
os << "\n";
- return 1;
}
-int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
+void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
{
// we output bottomlines of row r and the toplines of row r+1
// if the latter do not span the whole tabular
for (col_type c = 0; c < ncols(); ++c) {
bottomline.push_back(bottomLine(cellIndex(row, c)));
topline.push_back(!lastrow && topLine(cellIndex(row + 1, c)));
- // If cell is part of a multirow and not the last or first cell of the
+ // If cell is part of a multirow and not the last cell of the
// multirow, no line must be drawn.
if (!lastrow)
if (isMultiRow(cellIndex(row, c))
- && isMultiRow(cellIndex(row + 1, c))) {
- bottomline[c] = false;
- topline[c] = false;
+ && isMultiRow(cellIndex(row + 1, c))
+ && cell_info[row + 1][c].multirow != CELL_BEGIN_OF_MULTIROW) {
+ bottomline[c] = false;
+ topline[c] = false;
}
nextrowset &= topline[c];
}
// do nothing if empty, OR incomplete row line with a topline in next row
if (nset == 0 || (nextrowset && nset != ncols()))
- return 0;
+ return;
if (nset == ncols()) {
if (use_booktabs)
}
}
os << "\n";
- return 1;
}
-int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
- bool & ismulticol, bool & ismultirow) const
+void Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
+ bool & ismulticol, bool & ismultirow) const
{
- int ret = 0;
row_type const r = cellRow(cell);
if (is_long_tabular && row_info[r].caption)
- return ret;
+ return;
Tabular::VAlignment valign = getVAlignment(cell, !isMultiColumn(cell));
LyXAlignment align = getAlignment(cell, !isMultiColumn(cell));
|| (coldouble != celldouble);
// we center in multicol when no decimal point
- ismulticol |= ((column_info[c].alignment == LYX_ALIGN_DECIMAL)
- && (cellInfo(cell).decimal_width == 0));
+ if (column_info[c].alignment == LYX_ALIGN_DECIMAL) {
+ docstring const align_d = column_info[c].decimal_point;
+ DocIterator const dit = separatorPos(cellInset(cell).get(), align_d);
+ ismulticol |= !dit;
+ }
// up counter by 1 for each decimally aligned col since they use 2 latex cols
int latexcolspan = columnSpan(cell);
if (getRotateCell(cell)) {
os << "\\begin{sideways}\n";
- ++ret;
}
if (getUsebox(cell) == BOX_PARBOX) {
os << "\\parbox[";
}
os << "]{" << from_ascii(getPWidth(cell).asLatexString())
<< "}\n";
- ++ret;
}
- return ret;
}
-int Tabular::TeXCellPostamble(otexstream & os, idx_type cell,
- bool ismulticol, bool ismultirow) const
+void Tabular::TeXCellPostamble(otexstream & os, idx_type cell,
+ bool ismulticol, bool ismultirow) const
{
- int ret = 0;
row_type const r = cellRow(cell);
if (is_long_tabular && row_info[r].caption)
- return ret;
+ return;
// usual cells
if (getUsebox(cell) == BOX_PARBOX)
os << '}';
- else if (getUsebox(cell) == BOX_MINIPAGE) {
- os << "%\n\\end{minipage}";
- ret += 2;
- }
- if (getRotateCell(cell)) {
- os << "%\n\\end{sideways}";
- ++ret;
- }
+ else if (getUsebox(cell) == BOX_MINIPAGE)
+ os << breakln << "\\end{minipage}";
+ if (getRotateCell(cell))
+ os << breakln << "\\end{sideways}";
if (ismultirow)
os << '}';
if (ismulticol)
os << '}';
-
- return ret;
}
-int Tabular::TeXLongtableHeaderFooter(otexstream & os,
- OutputParams const & runparams) const
+void Tabular::TeXLongtableHeaderFooter(otexstream & os,
+ OutputParams const & runparams) const
{
if (!is_long_tabular)
- return 0;
+ return;
- int ret = 0;
// caption handling
// the caption must be output before the headers
if (haveLTCaption()) {
for (row_type r = 0; r < nrows(); ++r) {
- if (row_info[r].caption) {
- ret += TeXRow(os, r, runparams);
- }
+ if (row_info[r].caption)
+ TeXRow(os, r, runparams);
}
}
// output first header info
// first header must be output before the header, otherwise the
// correct caption placement becomes really weird
if (haveLTFirstHead()) {
- if (endfirsthead.topDL) {
+ if (endfirsthead.topDL)
os << "\\hline\n";
- ++ret;
- }
for (row_type r = 0; r < nrows(); ++r) {
- if (row_info[r].endfirsthead) {
- ret += TeXRow(os, r, runparams);
- }
+ if (row_info[r].endfirsthead)
+ TeXRow(os, r, runparams);
}
- if (endfirsthead.bottomDL) {
+ if (endfirsthead.bottomDL)
os << "\\hline\n";
- ++ret;
- }
os << "\\endfirsthead\n";
- ++ret;
}
// output header info
if (haveLTHead()) {
- if (endfirsthead.empty && !haveLTFirstHead()) {
+ if (endfirsthead.empty && !haveLTFirstHead())
os << "\\endfirsthead\n";
- ++ret;
- }
- if (endhead.topDL) {
+ if (endhead.topDL)
os << "\\hline\n";
- ++ret;
- }
for (row_type r = 0; r < nrows(); ++r) {
- if (row_info[r].endhead) {
- ret += TeXRow(os, r, runparams);
- }
+ if (row_info[r].endhead)
+ TeXRow(os, r, runparams);
}
- if (endhead.bottomDL) {
+ if (endhead.bottomDL)
os << "\\hline\n";
- ++ret;
- }
os << "\\endhead\n";
- ++ret;
}
// output footer info
if (haveLTFoot()) {
- if (endfoot.topDL) {
+ if (endfoot.topDL)
os << "\\hline\n";
- ++ret;
- }
for (row_type r = 0; r < nrows(); ++r) {
- if (row_info[r].endfoot) {
- ret += TeXRow(os, r, runparams);
- }
+ if (row_info[r].endfoot)
+ TeXRow(os, r, runparams);
}
- if (endfoot.bottomDL) {
+ if (endfoot.bottomDL)
os << "\\hline\n";
- ++ret;
- }
os << "\\endfoot\n";
- ++ret;
- if (endlastfoot.empty && !haveLTLastFoot()) {
+ if (endlastfoot.empty && !haveLTLastFoot())
os << "\\endlastfoot\n";
- ++ret;
- }
}
// output lastfooter info
if (haveLTLastFoot()) {
- if (endlastfoot.topDL) {
+ if (endlastfoot.topDL)
os << "\\hline\n";
- ++ret;
- }
for (row_type r = 0; r < nrows(); ++r) {
- if (row_info[r].endlastfoot) {
- ret += TeXRow(os, r, runparams);
- }
+ if (row_info[r].endlastfoot)
+ TeXRow(os, r, runparams);
}
- if (endlastfoot.bottomDL) {
+ if (endlastfoot.bottomDL)
os << "\\hline\n";
- ++ret;
- }
os << "\\endlastfoot\n";
- ++ret;
}
- return ret;
}
}
-int Tabular::TeXRow(otexstream & os, row_type row,
- OutputParams const & runparams) const
+void Tabular::TeXRow(otexstream & os, row_type row,
+ OutputParams const & runparams) const
{
idx_type cell = cellIndex(row, 0);
shared_ptr<InsetTableCell> inset = cellInset(cell);
string const lang = par.getParLanguage(buffer().params())->lang();
//output the top line
- int ret = TeXTopHLine(os, row, lang);
+ TeXTopHLine(os, row, lang);
if (row_info[row].top_space_default) {
if (use_booktabs)
os << "\\addlinespace\n";
else
os << "\\noalign{\\vskip\\doublerulesep}\n";
- ++ret;
} else if(!row_info[row].top_space.zero()) {
if (use_booktabs)
os << "\\addlinespace["
<< from_ascii(row_info[row].top_space.asLatexString())
<< "}\n";
}
- ++ret;
}
bool ismulticol = false;
bool ismultirow = false;
for (col_type c = 0; c < ncols(); ++c) {
if (isPartOfMultiColumn(row, c))
continue;
-
- if (isPartOfMultiRow(row, c) &&
- column_info[c].alignment != LYX_ALIGN_DECIMAL) {
- os << " & ";
+
+ cell = cellIndex(row, c);
+
+ if (isPartOfMultiRow(row, c)
+ && column_info[c].alignment != LYX_ALIGN_DECIMAL) {
+ if (cell != getLastCellInRow(row))
+ os << " & ";
continue;
}
- cell = cellIndex(row, c);
- ret += TeXCellPreamble(os, cell, ismulticol, ismultirow);
+ TeXCellPreamble(os, cell, ismulticol, ismultirow);
shared_ptr<InsetTableCell> inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front();
? OutputParams::PLAIN
: OutputParams::ALIGNED;
- if (getAlignment(cell) == LYX_ALIGN_DECIMAL
- && cellInfo(cell).decimal_width != 0) {
+ if (getAlignment(cell) == LYX_ALIGN_DECIMAL) {
// copy cell and split in 2
InsetTableCell head = InsetTableCell(*cellInset(cell).get());
- head.getText(0)->setMacrocontextPosition(
- cellInset(cell)->getText(0)->macrocontextPosition());
head.setBuffer(buffer());
+ DocIterator dit = cellInset(cell)->getText(0)->macrocontextPosition();
+ dit.pop_back();
+ dit.push_back(CursorSlice(head));
+ head.setMacrocontextPositionRecursive(dit);
bool hassep = false;
InsetTableCell tail = splitCell(head, column_info[c].decimal_point, hassep);
- tail.getText(0)->setMacrocontextPosition(
- head.getText(0)->macrocontextPosition());
- tail.setBuffer(head.buffer());
head.latex(os, newrp);
- os << '&';
- ret += tail.latex(os, newrp);
- } else if (!isPartOfMultiRow(row, c))
- ret += inset->latex(os, newrp);
+ if (hassep) {
+ os << '&';
+ tail.setBuffer(head.buffer());
+ dit.pop_back();
+ dit.push_back(CursorSlice(tail));
+ tail.setMacrocontextPositionRecursive(dit);
+ tail.latex(os, newrp);
+ }
+ } else if (!isPartOfMultiRow(row, c)) {
+ if (!runparams.nice)
+ os.texrow().start(par.id(), 0);
+ inset->latex(os, newrp);
+ }
runparams.encoding = newrp.encoding;
if (rtl)
os << '}';
- ret += TeXCellPostamble(os, cell, ismulticol, ismultirow);
+ TeXCellPostamble(os, cell, ismulticol, ismultirow);
if (cell != getLastCellInRow(row)) { // not last cell in row
- os << " & ";
+ if (runparams.nice)
+ os << " & ";
+ else
+ os << " &\n";
}
}
if (row_info[row].caption && !endfirsthead.empty && !haveLTFirstHead())
<< ']';
}
os << '\n';
- ++ret;
//output the bottom line
- ret += TeXBottomHLine(os, row, lang);
+ TeXBottomHLine(os, row, lang);
if (row_info[row].interline_space_default) {
if (use_booktabs)
os << "\\addlinespace\n";
else
os << "\\noalign{\\vskip\\doublerulesep}\n";
- ++ret;
} else if (!row_info[row].interline_space.zero()) {
if (use_booktabs)
os << "\\addlinespace["
os << "\\noalign{\\vskip"
<< from_ascii(row_info[row].interline_space.asLatexString())
<< "}\n";
- ++ret;
}
- return ret;
}
-int Tabular::latex(otexstream & os, OutputParams const & runparams) const
+void Tabular::latex(otexstream & os, OutputParams const & runparams) const
{
- int ret = 0;
bool const is_tabular_star = !tabular_width.zero();
//+---------------------------------------------------------------------
//+ first the opening preamble +
//+---------------------------------------------------------------------
- if (rotate) {
+ os << safebreakln;
+ if (runparams.lastid != -1)
+ os.texrow().start(runparams.lastid, runparams.lastpos);
+
+ if (rotate)
os << "\\begin{sideways}\n";
- ++ret;
- }
+
if (is_long_tabular) {
os << "\\begin{longtable}";
switch (longtabular_alignment) {
os << '|';
}
os << "}\n";
- ++ret;
- ret += TeXLongtableHeaderFooter(os, runparams);
+ TeXLongtableHeaderFooter(os, runparams);
//+---------------------------------------------------------------------
//+ the single row and columns (cells) +
for (row_type r = 0; r < nrows(); ++r) {
if (isValidRow(r)) {
- ret += TeXRow(os, r, runparams);
- if (is_long_tabular && row_info[r].newpage) {
+ TeXRow(os, r, runparams);
+ if (is_long_tabular && row_info[r].newpage)
os << "\\newpage\n";
- ++ret;
- }
}
}
if (is_long_tabular)
os << "\\end{longtable}";
- else
+ else {
if (is_tabular_star)
os << "\\end{tabular*}";
else
os << "\\end{tabular}";
- if (rotate) {
- // clear counter
- os.countLines();
- os << breakln << "\\end{sideways}";
- ret += os.countLines();
}
- return ret;
+ if (rotate)
+ os << breakln << "\\end{sideways}";
}
xs << html::StartTag("tr");
for (col_type c = 0; c < ncols(); ++c) {
- if (isPartOfMultiColumn(row, c))
+ if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c))
continue;
stringstream attr;
if (isMultiColumn(cell))
attr << " colspan='" << columnSpan(cell) << "'";
+ else if (isMultiRow(cell))
+ attr << " rowspan='" << rowSpan(cell) << "'";
- xs << html::StartTag(celltag, attr.str());
+ xs << html::StartTag(celltag, attr.str()) << html::CR();
ret += cellInset(cell)->xhtml(xs, runparams);
- xs << html::EndTag(celltag);
+ xs << html::EndTag(celltag) << html::CR();
++cell;
}
xs << html::EndTag("tr");
align = "right";
break;
}
- xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'");
+ xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'")
+ << html::CR();
if (haveLTCaption()) {
- xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'");
+ xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'")
+ << html::CR();
for (row_type r = 0; r < nrows(); ++r)
if (row_info[r].caption)
ret += xhtmlRow(xs, r, runparams);
- xs << html::EndTag("div");
+ xs << html::EndTag("div") << html::CR();
}
}
- xs << html::StartTag("table");
+ xs << html::StartTag("table") << html::CR();
// output header info
bool const havefirsthead = haveLTFirstHead();
// in XHTML. this test accomplishes that.
bool const havehead = !havefirsthead && haveLTHead();
if (havehead || havefirsthead) {
- xs << html::StartTag("thead");
+ xs << html::StartTag("thead") << html::CR();
for (row_type r = 0; r < nrows(); ++r) {
if ((havefirsthead && row_info[r].endfirsthead)
|| (havehead && row_info[r].endhead)) {
ret += xhtmlRow(xs, r, runparams, true);
}
}
- xs << html::EndTag("thead");
+ xs << html::EndTag("thead") << html::CR();
}
// output footer info
bool const havelastfoot = haveLTLastFoot();
// as before.
bool const havefoot = !havelastfoot && haveLTFoot();
if (havefoot || havelastfoot) {
- xs << html::StartTag("tfoot");
+ xs << html::StartTag("tfoot") << html::CR();
for (row_type r = 0; r < nrows(); ++r) {
if ((havelastfoot && row_info[r].endlastfoot)
|| (havefoot && row_info[r].endfoot)) {
ret += xhtmlRow(xs, r, runparams);
}
}
- xs << html::EndTag("tfoot");
+ xs << html::EndTag("tfoot") << html::CR();
}
- xs << html::StartTag("tbody");
+ xs << html::StartTag("tbody") << html::CR();
for (row_type r = 0; r < nrows(); ++r) {
if (isValidRow(r)) {
ret += xhtmlRow(xs, r, runparams);
}
}
xs << html::EndTag("tbody")
- << html::EndTag("table");
+ << html::CR()
+ << html::EndTag("table")
+ << html::CR();
if (is_long_tabular)
- xs << html::EndTag("div");
+ xs << html::EndTag("div") << html::CR();
return ret;
}
if (!onlydata && plaintextTopHLine(os, r, clen))
os << docstring(depth * 2, ' ');
for (col_type c = 0; c < ncols(); ++c) {
- if (isPartOfMultiColumn(r, c))
+ if (isPartOfMultiColumn(r, c) || isPartOfMultiRow(r,c))
continue;
if (onlydata && c > 0)
// we don't use operator<< for single UCS4 character.
mi.base.bv->textMetrics(tabular.cellInset(cell)->getText(0));
// determine horizontal offset because of decimal align (if necessary)
- int decimal_hoffset = 0;
int decimal_width = 0;
if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) {
- // make a copy which we will split in 2
- InsetTableCell head = InsetTableCell(*tabular.cellInset(cell).get());
- head.getText(0)->setMacrocontextPosition(
- tabular.cellInset(cell)->getText(0)->macrocontextPosition());
- head.setBuffer(tabular.buffer());
- // split in 2 and calculate width of each part
- bool hassep = false;
- InsetTableCell tail =
- splitCell(head, tabular.column_info[c].decimal_point, hassep);
- tail.getText(0)->setMacrocontextPosition(
- head.getText(0)->macrocontextPosition());
- tail.setBuffer(head.buffer());
- Dimension dim1;
- head.metrics(m, dim1);
- decimal_hoffset = dim1.width();
- if (hassep) {
+ InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell).get());
+ tail.setBuffer(tabular.buffer());
+ // we need to set macrocontext position everywhere
+ // otherwise we crash with nested insets (e.g. footnotes)
+ // after decimal point
+ DocIterator dit = tabular.cellInset(cell)->getText(0)->macrocontextPosition();
+ dit.pop_back();
+ dit.push_back(CursorSlice(tail));
+ tail.setMacrocontextPositionRecursive(dit);
+
+ // remove text leading decimal point
+ docstring const align_d = tabular.column_info[c].decimal_point;
+ dit = separatorPos(&tail, align_d);
+
+ pit_type const psize = tail.paragraphs().front().size();
+ if (dit) {
+ tail.paragraphs().front().eraseChars(0,
+ dit.pos() < psize ? dit.pos() + 1 : psize, false);
+ Dimension dim1;
tail.metrics(m, dim1);
decimal_width = dim1.width();
}
}
- tabular.cell_info[r][c].decimal_hoffset = decimal_hoffset;
+ tabular.cell_info[r][c].decimal_hoffset = tm.width() - decimal_width;
tabular.cell_info[r][c].decimal_width = decimal_width;
// with LYX_VALIGN_BOTTOM the descent is relative to the last par
cmd = FuncRequest(finish_lfun);
else
cur.dispatched();
+
+ cur.screenUpdateFlags(Update::Force | Update::FitCursor);
break;
}
// setting also the right targetX.
cur.selHandle(act == LFUN_DOWN_SELECT);
if (tabular.cellRow(cur.idx()) != tabular.nrows() - 1) {
+ int const xtarget = cur.targetX();
+ // WARNING: Once cur.idx() has been reset, the cursor is in
+ // an inconsistent state until pos() has been set. Be careful
+ // what you do with it!
cur.idx() = tabular.cellBelow(cur.idx());
cur.pit() = 0;
TextMetrics const & tm =
cur.bv().textMetrics(cell(cur.idx())->getText(0));
- cur.pos() = tm.x2pos(cur.pit(), 0, cur.targetX());
+ cur.pos() = tm.x2pos(cur.pit(), 0, xtarget);
cur.setCurrentFont();
}
}
cur.setCurrentFont();
return;
}
+ cur.screenUpdateFlags(Update::FitCursor);
break;
case LFUN_UP_SELECT:
// setting also the right targetX.
cur.selHandle(act == LFUN_UP_SELECT);
if (tabular.cellRow(cur.idx()) != 0) {
+ int const xtarget = cur.targetX();
+ // WARNING: Once cur.idx() has been reset, the cursor is in
+ // an inconsistent state until pos() has been set. Be careful
+ // what you do with it!
cur.idx() = tabular.cellAbove(cur.idx());
cur.pit() = cur.lastpit();
Text const * text = cell(cur.idx())->getText(0);
TextMetrics const & tm = cur.bv().textMetrics(text);
ParagraphMetrics const & pm =
tm.parMetrics(cur.lastpit());
- cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, cur.targetX());
+ cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, xtarget);
cur.setCurrentFont();
}
}
cur.setCurrentFont();
return;
}
+ cur.screenUpdateFlags(Update::FitCursor);
break;
// case LFUN_SCREEN_DOWN: {
if (&cur.inset() != this || cmd.getArg(0) != "tabular")
break;
- string const s = cmd.getArg(1);
// FIXME: We only check for the very first argument...
+ string const s = cmd.getArg(1);
+ // We always enable the lfun if it is coming from the dialog
+ // because the dialog makes sure all the settings are valid,
+ // even though the first argument might not be valid now.
+ if (s == "from-dialog") {
+ status.setEnabled(true);
+ return true;
+ }
+
int action = Tabular::LAST_ACTION;
int i = 0;
for (; tabularFeature[i].action != Tabular::LAST_ACTION; ++i) {
}
// disable in non-fixed-width cells
- case LFUN_NEWLINE_INSERT:
- case LFUN_BREAK_PARAGRAPH: {
+ case LFUN_BREAK_PARAGRAPH:
+ // multirow does not allow paragraph breaks
+ if (tabular.isMultiRow(cur.idx())) {
+ status.setEnabled(false);
+ return true;
+ }
+ case LFUN_NEWLINE_INSERT: {
if (tabular.getPWidth(cur.idx()).zero()) {
status.setEnabled(false);
return true;
}
-int InsetTabular::latex(otexstream & os, OutputParams const & runparams) const
+void InsetTabular::latex(otexstream & os, OutputParams const & runparams) const
{
- return tabular.latex(os, runparams);
+ tabular.latex(os, runparams);
}
if (len.zero()
&& tabular.getAlignment(cur.idx(), true) == LYX_ALIGN_BLOCK)
tabularFeatures(cur, Tabular::ALIGN_CENTER, string());
- // check if there is a 1-column multicolumn cell
- // if so it must get the same width
- for (row_type r = 0; r < tabular.nrows(); ++r) {
- if (tabular.isMultiColumn(tabular.cellIndex(r, column))
- && tabular.columnSpan(tabular.cellIndex(r, column)) == 1)
- tabular.setMColumnPWidth(cur, tabular.cellIndex(r, column), len);
- }
break;
}
case Tabular::SET_MPWIDTH:
tabular.setMColumnPWidth(cur, cur.idx(), Length(value));
- // if the multicolumn only spans 1 column, the width of the whole column
- // must have the same width, see bug #7055
- if (tabular.columnSpan(cur.idx()) == 1)
- for (row_type r = 0; r < tabular.nrows(); ++r) {
- if (!tabular.isMultiColumn(tabular.cellIndex(r, column)))
- tabular.setColumnPWidth(cur, tabular.cellIndex(r, column), Length(value));
- else if (tabular.isMultiColumn(tabular.cellIndex(r, column))
- && tabular.columnSpan(tabular.cellIndex(r, column)) == 1)
- tabular.setMColumnPWidth(cur, tabular.cellIndex(r, column), Length(value));
- }
break;
case Tabular::SET_MROFFSET:
// just multirow for one single cell
// check whether we are completely in a multirow
if (!tabular.isMultiRow(cur.idx()))
- tabular.setMultiRow(cur.idx(), 1);
+ tabular.setMultiRow(cur.idx(), 1,
+ tabular.bottomLine(cur.idx()));
break;
}
// we have a selection so this means we just add all this
idx_type const s_start = cur.selBegin().idx();
row_type const row_start = tabular.cellRow(s_start);
row_type const row_end = tabular.cellRow(cur.selEnd().idx());
- cur.idx() = tabular.setMultiRow(s_start, row_end - row_start + 1);
+ cur.idx() = tabular.setMultiRow(s_start, row_end - row_start + 1,
+ tabular.bottomLine(cur.selEnd().idx()));
cur.pit() = 0;
cur.pos() = 0;
cur.setSelection(false);