Buffer const & buffer = cur.buffer();
pit_type pit = cur.pit();
pos_type pos = cur.pos();
- ParagraphList & pars = cur.text()->paragraphs();
+ InsetText * target_inset = cur.inset().asInsetText();
+ if (!target_inset) {
+ InsetTabular * it = cur.inset().asInsetTabular();
+ target_inset = it? it->cell(cur.idx())->asInsetText() : 0;
+ }
+ LASSERT(target_inset, return make_pair(PitPosPair(pit, pos), pit));
+ ParagraphList & pars = target_inset->paragraphs();
if (parlist.empty())
return make_pair(PitPosPair(pit, pos), pit);
// Convert newline to paragraph break in ERT inset.
// This should not be here!
- Inset * inset = pars[pit].inInset();
- if (inset && (inset->lyxCode() == ERT_CODE ||
- inset->lyxCode() == LISTINGS_CODE)) {
+ InsetCode const code = target_inset->lyxCode();
+ if (code == ERT_CODE || code == LISTINGS_CODE) {
for (size_t i = 0; i != insertion.size(); ++i) {
for (pos_type j = 0; j != insertion[i].size(); ++j) {
if (insertion[i].isNewline(j)) {
// do not track deletion of newline
insertion[i].eraseChar(j, false);
+ insertion[i].setInsetOwner(target_inset);
breakParagraphConservative(
buffer.params(),
insertion, i, j);
max_depth = tmpbuf->getMaxDepthAfter();
// Set the inset owner of this paragraph.
- tmpbuf->setInsetOwner(pars[pit].inInset());
+ tmpbuf->setInsetOwner(target_inset);
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
// do not track deletion of invalid insets
if (Inset * inset = tmpbuf->getInset(i))
- if (!pars[pit].insetAllowed(inset->lyxCode()))
+ if (!target_inset->insetAllowed(inset->lyxCode()))
tmpbuf->eraseChar(i--, false);
}
}
-void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
+void copySelectionHelper(Buffer const & buf, ParagraphList const & pars,
pit_type startpit, pit_type endpit,
int start, int end, DocumentClass const * const dc, CutStack & cutstack)
{
}
-void copySelection(Cursor & cur)
+void copySelection(Cursor const & cur)
{
copySelection(cur, cur.selectionAsString(true));
}
namespace {
-void copySelectionToStack(Cursor & cur, CutStack & cutstack)
+void copySelectionToStack(Cursor const & cur, CutStack & cutstack)
{
// this doesn't make sense, if there is no selection
if (!cur.selection())
}
-void copySelection(Cursor & cur, docstring const & plaintext)
+void copySelection(Cursor const & cur, docstring const & plaintext)
{
// In tablemode, because copy and paste actually use special table stack
// we do not attempt to get selected paragraphs under cursor. Instead, a
}
-void saveSelection(Cursor & cur)
+void saveSelection(Cursor const & cur)
{
// This function is called, not when a selection is formed, but when
// a selection is cleared. Therefore, multiple keyboard selection