mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 21:05:12 +00:00
Fix to bug 3886
acceptChanges: * move the bulk of acceptChanges without the call to DEPM to paragraph_funcs copySelectionHelper: * call this new acceptChanges pasteParagraphList: * use Text::setCursor(Cusor,...) instead of Text::setCursor(CursorSlice...) in order to have DEPM invoked at the end of the insertion git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18892 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2b2a95a784
commit
7bc7431b49
@ -388,12 +388,7 @@ void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do not copy text (also nested in insets) which is marked as deleted
|
// do not copy text (also nested in insets) which is marked as deleted
|
||||||
// acceptChanges() is defined for Text rather than ParagraphList
|
acceptChanges(copy_pars, buf.params());
|
||||||
// Thus we must wrap copy_pars into a Text object and cross our fingers
|
|
||||||
Text lt;
|
|
||||||
copy_pars.swap(lt.paragraphs());
|
|
||||||
lt.acceptChanges(buf.params());
|
|
||||||
copy_pars.swap(lt.paragraphs());
|
|
||||||
|
|
||||||
cutstack.push(make_pair(copy_pars, tc));
|
cutstack.push(make_pair(copy_pars, tc));
|
||||||
}
|
}
|
||||||
@ -723,7 +718,7 @@ void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
|||||||
textclass, errorList);
|
textclass, errorList);
|
||||||
updateLabels(cur.buffer());
|
updateLabels(cur.buffer());
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
text->setCursor(cur.top(), ppp.first, ppp.second);
|
text->setCursor(cur, ppp.first, ppp.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mathed is handled in InsetMathNest/InsetMathGrid
|
// mathed is handled in InsetMathNest/InsetMathGrid
|
||||||
|
32
src/Text.cpp
32
src/Text.cpp
@ -993,36 +993,8 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
|||||||
|
|
||||||
void Text::acceptChanges(BufferParams const & bparams)
|
void Text::acceptChanges(BufferParams const & bparams)
|
||||||
{
|
{
|
||||||
pit_type pars_size = static_cast<pit_type>(pars_.size());
|
lyx::acceptChanges(pars_, bparams);
|
||||||
|
deleteEmptyParagraphMechanism(0, pars_.size() - 1, bparams.trackChanges);
|
||||||
// first, accept changes within each individual paragraph
|
|
||||||
// (do not consider end-of-par)
|
|
||||||
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
|
||||||
if (!pars_[pit].empty()) // prevent assertion failure
|
|
||||||
pars_[pit].acceptChanges(bparams, 0, pars_[pit].size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// next, accept imaginary end-of-par characters
|
|
||||||
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
|
||||||
pos_type pos = pars_[pit].size();
|
|
||||||
|
|
||||||
if (pars_[pit].isInserted(pos)) {
|
|
||||||
pars_[pit].setChange(pos, Change(Change::UNCHANGED));
|
|
||||||
} else if (pars_[pit].isDeleted(pos)) {
|
|
||||||
if (pit == pars_size - 1) {
|
|
||||||
// we cannot remove a par break at the end of the last
|
|
||||||
// paragraph; instead, we mark it unchanged
|
|
||||||
pars_[pit].setChange(pos, Change(Change::UNCHANGED));
|
|
||||||
} else {
|
|
||||||
mergeParagraph(bparams, pars_, pit);
|
|
||||||
--pit;
|
|
||||||
--pars_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// finally, invoke the DEPM
|
|
||||||
deleteEmptyParagraphMechanism(0, pars_size - 1, bparams.trackChanges);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,4 +317,36 @@ int numberOfOptArgs(Paragraph const & par)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void acceptChanges(ParagraphList & pars, BufferParams const & bparams)
|
||||||
|
{
|
||||||
|
pit_type pars_size = static_cast<pit_type>(pars.size());
|
||||||
|
|
||||||
|
// first, accept changes within each individual paragraph
|
||||||
|
// (do not consider end-of-par)
|
||||||
|
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
||||||
|
if (!pars[pit].empty()) // prevent assertion failure
|
||||||
|
pars[pit].acceptChanges(bparams, 0, pars[pit].size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// next, accept imaginary end-of-par characters
|
||||||
|
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
||||||
|
pos_type pos = pars[pit].size();
|
||||||
|
|
||||||
|
if (pars[pit].isInserted(pos)) {
|
||||||
|
pars[pit].setChange(pos, Change(Change::UNCHANGED));
|
||||||
|
} else if (pars[pit].isDeleted(pos)) {
|
||||||
|
if (pit == pars_size - 1) {
|
||||||
|
// we cannot remove a par break at the end of the last
|
||||||
|
// paragraph; instead, we mark it unchanged
|
||||||
|
pars[pit].setChange(pos, Change(Change::UNCHANGED));
|
||||||
|
} else {
|
||||||
|
mergeParagraph(bparams, pars, pit);
|
||||||
|
--pit;
|
||||||
|
--pars_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -75,6 +75,9 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars);
|
|||||||
/// return the number of InsetOptArg in a paragraph
|
/// return the number of InsetOptArg in a paragraph
|
||||||
int numberOfOptArgs(Paragraph const & par);
|
int numberOfOptArgs(Paragraph const & par);
|
||||||
|
|
||||||
|
/// accept the changes within the complete ParagraphList
|
||||||
|
void acceptChanges(ParagraphList & pars, BufferParams const & bparams);
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user