&& cellInfo(cell).decimal_width != 0) {
// 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());
+ dit.pop_back();
+ dit.push_back(CursorSlice(tail));
+ tail.setMacrocontextPositionRecursive(dit);
head.latex(os, newrp);
os << '&';
tail.latex(os, newrp);
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 = doc_iterator_begin(&tail.buffer(), &tail);
+ for (; dit; dit.forwardChar())
+ if (dit.inTexted() && dit.depth()==1
+ && dit.paragraph().find(align_d, false, false, dit.pos()))
+ break;
+
+ 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
}
+void InsetText::setMacrocontextPositionRecursive(DocIterator const & pos)
+{
+ text_.setMacrocontextPosition(pos);
+
+ ParagraphList::const_iterator pit = paragraphs().begin();
+ ParagraphList::const_iterator pend = paragraphs().end();
+ for (; pit != pend; ++pit) {
+ InsetList::const_iterator iit = pit->insetList().begin();
+ InsetList::const_iterator end = pit->insetList().end();
+ for (; iit != end; ++iit) {
+ if (InsetText * txt = iit->inset->asInsetText()) {
+ DocIterator ppos(pos);
+ ppos.push_back(CursorSlice(*txt));
+ iit->inset->asInsetText()->setMacrocontextPositionRecursive(ppos);
+ }
+ }
+ }
+}
+
+
void InsetText::clear()
{
ParagraphList & pars = paragraphs();