mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 14:29:21 +00:00
partial revert of earlier patch avoids crash
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10245 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ef8e527612
commit
49d8c0d3e0
@ -99,19 +99,14 @@ bool checkPastePossible(int index)
|
||||
}
|
||||
|
||||
|
||||
void pasteSelectionHelper(LCursor & cur, size_t cut_index)
|
||||
pair<PitPosPair, pit_type>
|
||||
pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
|
||||
pit_type pit, int pos,
|
||||
textclass_type tc, size_t cut_index, ErrorList & errorlist)
|
||||
{
|
||||
recordUndo(cur);
|
||||
Buffer const & buffer = cur.buffer();
|
||||
InsetText & inset = static_cast<InsetText &>(cur.inset());
|
||||
pit_type pit = cur.pit();
|
||||
pos_type pos = cur.pos();
|
||||
pit_type endpit = pit;
|
||||
textclass_type const & tc = buffer.params().textclass;
|
||||
ErrorList errorlist;
|
||||
if (!checkPastePossible(cut_index))
|
||||
return make_pair(PitPosPair(pit, pos), pit);
|
||||
|
||||
if (checkPastePossible(cut_index)) {
|
||||
ParagraphList & pars = inset.paragraphs();
|
||||
BOOST_ASSERT (pos <= pars[pit].size());
|
||||
|
||||
// Make a copy of the CaP paragraphs.
|
||||
@ -168,7 +163,7 @@ void pasteSelectionHelper(LCursor & cur, size_t cut_index)
|
||||
tmpbuf->setInsetOwner(pars[pit].inInset());
|
||||
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
|
||||
if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
|
||||
!inset.insetAllowed(tmpbuf->getInset(i)->lyxCode()))
|
||||
!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
|
||||
tmpbuf->erase(i--);
|
||||
}
|
||||
}
|
||||
@ -249,17 +244,7 @@ void pasteSelectionHelper(LCursor & cur, size_t cut_index)
|
||||
}
|
||||
}
|
||||
|
||||
endpit = last_paste + 1;
|
||||
}
|
||||
|
||||
bufferErrors(cur.buffer(), errorlist);
|
||||
cur.bv().showErrorList(_("Paste"));
|
||||
cur.clearSelection();
|
||||
cur.resetAnchor();
|
||||
BOOST_ASSERT(cur.text());
|
||||
cur.text()->setCursor(cur, pit, pos);
|
||||
cur.setSelection();
|
||||
updateCounters(cur.buffer());
|
||||
return make_pair(PitPosPair(pit, pos), last_paste + 1);
|
||||
}
|
||||
|
||||
|
||||
@ -357,9 +342,23 @@ void copySelectionHelper(ParagraphList & pars,
|
||||
theCuts.push(make_pair(paragraphs, tc));
|
||||
}
|
||||
|
||||
|
||||
|
||||
PitPosPair cutSelectionHelper(BufferParams const & params,
|
||||
ParagraphList & pars, pit_type startpit, pit_type endpit,
|
||||
int startpos, int endpos, textclass_type tc, bool doclear)
|
||||
{
|
||||
copySelectionHelper(pars, startpit, endpit, startpos, endpos, tc);
|
||||
return eraseSelectionHelper(params, pars, startpit, endpit,
|
||||
startpos, endpos, doclear);
|
||||
}
|
||||
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace cap {
|
||||
|
||||
@ -576,7 +575,7 @@ void copySelection(LCursor & cur)
|
||||
}
|
||||
|
||||
if (cur.inMathed()) {
|
||||
//lyxerr << "copySelection in mathed" << endl;
|
||||
lyxerr << "copySelection in mathed" << endl;
|
||||
ParagraphList pars;
|
||||
pars.push_back(Paragraph());
|
||||
BufferParams const & bp = cur.buffer().params();
|
||||
@ -599,12 +598,40 @@ std::string getSelection(Buffer const & buf, size_t sel_index)
|
||||
void pasteSelection(LCursor & cur, size_t sel_index)
|
||||
{
|
||||
// this does not make sense, if there is nothing to paste
|
||||
lyxerr << "#### pasteSelection " << sel_index << endl;
|
||||
if (!checkPastePossible(sel_index))
|
||||
return;
|
||||
if (cur.inTexted())
|
||||
pasteSelectionHelper(cur, sel_index);
|
||||
if (cur.inMathed())
|
||||
|
||||
if (cur.inTexted()) {
|
||||
LyXText * text = cur.text();
|
||||
BOOST_ASSERT(text);
|
||||
|
||||
recordUndo(cur);
|
||||
|
||||
pit_type endpit;
|
||||
PitPosPair ppp;
|
||||
|
||||
ErrorList el;
|
||||
|
||||
boost::tie(ppp, endpit) =
|
||||
pasteSelectionHelper(cur.buffer(),
|
||||
text->paragraphs(),
|
||||
cur.pit(), cur.pos(),
|
||||
cur.buffer().params().textclass,
|
||||
sel_index, el);
|
||||
bufferErrors(cur.buffer(), el);
|
||||
cur.bv().showErrorList(_("Paste"));
|
||||
|
||||
cur.clearSelection();
|
||||
cur.resetAnchor();
|
||||
text->setCursor(cur, ppp.first, ppp.second);
|
||||
cur.setSelection();
|
||||
updateCounters(cur.buffer());
|
||||
}
|
||||
|
||||
if (cur.inMathed()) {
|
||||
lyxerr << "### should be handled in MathNest/GridInset" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user