Juergen Spitzmueller wrote:

> http://bugzilla.lyx.org/show_bug.cgi?id=1952
> 
> Has anyone an idea why the inset owner of tabular cells is set to tabular,
> not insettext, after undo (which is the reason for this bug)?
> The relevant code seems to be the following, but I do not understand it:
> 
> undo.C:185
> for (; pit != end; ++pit)
>         const_cast<Paragraph&>(*pit).setInsetOwner(&dit.inset());

I believe that the cursor can never go into a single cell of a tabluar, only
in a tabular as a whole. The cells are addressed via LCursor::idx().
Therefore dit.inset() returns the tabular inset, and not the cell.

I guess something like

ParagraphList::iterator pit = plist.end() - undo.pars.size();
ParagraphList::iterator const end = plist.end();
InsetBase * inset;
if (dit.inset().lyxCode() == InsetBase::TABULAR_CODE) {
        InsetTabular & tabular = static_cast<InsetTabular&>(dit.inset());
        inset = tabular.cell(dit.idx()).get();
} else
        inset = &dit.inset();
for (; pit != end; ++pit)
        pit->setInsetOwner(inset);

should fix it. This assumes that only one cell can be undone at a time, so
that the cell is the same for the whole paragraph list.


Georg

Reply via email to