mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 22:49:20 +00:00
change tracking:
* paragraph_funcs.C: moveItem(): rename and reorder parameters to make the function better understandable; do not pass a Change parameter, because the function is able to retrieve the right change by itself; adjust all function calls; simplify the CT code and remove 3 FIXMEs at the same time git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15756 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
99d066de95
commit
c15a94ccf0
@ -22,29 +22,29 @@ namespace lyx {
|
|||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
static bool moveItem(Paragraph & from, Paragraph & to,
|
static bool moveItem(Paragraph & fromPar, pos_type fromPos,
|
||||||
BufferParams const & params, pos_type i, pos_type j,
|
Paragraph & toPar, pos_type toPos, BufferParams const & params)
|
||||||
Change change = Change(Change::INSERTED))
|
|
||||||
{
|
{
|
||||||
Paragraph::value_type const tmpchar = from.getChar(i);
|
Paragraph::value_type const tmpChar = fromPar.getChar(fromPos);
|
||||||
LyXFont tmpfont = from.getFontSettings(params, i);
|
LyXFont const tmpFont = fromPar.getFontSettings(params, fromPos);
|
||||||
|
Change const tmpChange = fromPar.lookupChange(fromPos);
|
||||||
|
|
||||||
if (tmpchar == Paragraph::META_INSET) {
|
if (tmpChar == Paragraph::META_INSET) {
|
||||||
InsetBase * tmpinset = 0;
|
InsetBase * tmpInset = 0;
|
||||||
if (from.getInset(i)) {
|
if (fromPar.getInset(fromPos)) {
|
||||||
// the inset is not in a paragraph anymore
|
// the inset is not in a paragraph anymore
|
||||||
tmpinset = from.insetlist.release(i);
|
tmpInset = fromPar.insetlist.release(fromPos);
|
||||||
from.insetlist.erase(i);
|
fromPar.insetlist.erase(fromPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!to.insetAllowed(tmpinset->lyxCode())) {
|
if (!toPar.insetAllowed(tmpInset->lyxCode())) {
|
||||||
delete tmpinset;
|
delete tmpInset;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (tmpinset)
|
if (tmpInset)
|
||||||
to.insertInset(j, tmpinset, tmpfont, change);
|
toPar.insertInset(toPos, tmpInset, tmpFont, tmpChange);
|
||||||
} else {
|
} else {
|
||||||
to.insertChar(j, tmpchar, tmpfont, change);
|
toPar.insertChar(toPos, tmpChar, tmpFont, tmpChange);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,10 +106,7 @@ void breakParagraph(BufferParams const & bparams,
|
|||||||
pos_type pos_end = par.size() - 1;
|
pos_type pos_end = par.size() - 1;
|
||||||
|
|
||||||
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
||||||
Change::Type change = par.lookupChange(i).type;
|
if (moveItem(par, i, *tmp, j - pos, bparams)) {
|
||||||
if (moveItem(par, *tmp, bparams, i, j - pos)) {
|
|
||||||
// FIXME: change tracking (MG)
|
|
||||||
tmp->setChange(j - pos, Change(change));
|
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,10 +170,9 @@ void breakParagraphConservative(BufferParams const & bparams,
|
|||||||
pos_type pos_end = par.size() - 1;
|
pos_type pos_end = par.size() - 1;
|
||||||
|
|
||||||
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
||||||
Change::Type change = par.lookupChange(i).type;
|
if (moveItem(par, i, tmp, j - pos, bparams)) {
|
||||||
// FIXME: change tracking (MG)
|
|
||||||
if (moveItem(par, tmp, bparams, i, j - pos, Change(change)))
|
|
||||||
++j;
|
++j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Move over end-of-par change attr
|
// Move over end-of-par change attr
|
||||||
// FIXME: change tracking (MG)
|
// FIXME: change tracking (MG)
|
||||||
@ -221,10 +217,9 @@ void mergeParagraph(BufferParams const & bparams,
|
|||||||
Change::Type cr = next.lookupChange(next.size()).type;
|
Change::Type cr = next.lookupChange(next.size()).type;
|
||||||
// ok, now copy the paragraph
|
// ok, now copy the paragraph
|
||||||
for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
|
for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
|
||||||
Change::Type change = next.lookupChange(i).type;
|
if (moveItem(next, i, par, pos_insert + j, bparams)) {
|
||||||
// FIXME: change tracking (MG)
|
|
||||||
if (moveItem(next, par, bparams, i, pos_insert + j, Change(change)))
|
|
||||||
++j;
|
++j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Move the change status of "carriage return" over
|
// Move the change status of "carriage return" over
|
||||||
// FIXME: change tracking (MG)
|
// FIXME: change tracking (MG)
|
||||||
|
Loading…
Reference in New Issue
Block a user