+ tabular.cellInfo(cell).width = dim.wid + 2 * WIDTH_OF_LINE
+ + tabular.interColumnSpace(cell);
+
+ // FIXME(?): do we need a second metrics call?
+ TextMetrics const & tm =
+ mi.base.bv->textMetrics(tabular.cellInset(cell)->getText(0));
+
+ // determine horizontal offset because of decimal align (if necessary)
+ int decimal_width = 0;
+ if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) {
+ 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 = 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
+ // = descent of text in last par + TEXT_TO_INSET_OFFSET:
+ int const lastpardes = tm.last().second->descent()
+ + TEXT_TO_INSET_OFFSET;
+ int offset = 0;
+ switch (tabular.getVAlignment(cell)) {
+ case Tabular::LYX_VALIGN_TOP:
+ break;
+ case Tabular::LYX_VALIGN_MIDDLE:
+ offset = -(dim.des - lastpardes)/2;
+ break;
+ case Tabular::LYX_VALIGN_BOTTOM:
+ offset = -(dim.des - lastpardes);
+ break;
+ }
+ tabular.cell_info[r][c].voffset = offset;
+ maxasc = max(maxasc, dim.asc - offset);
+ maxdes = max(maxdes, dim.des + offset);