mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
redoParagraphs patch from Alfredo
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6666 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ce1f7f2578
commit
880919dc78
@ -1,3 +1,8 @@
|
|||||||
|
2003-04-01 Alfredo Braunstein <abraunst@libero.it>
|
||||||
|
|
||||||
|
* text2.C (redoParagraphs): fix a bug (introduced by myself) and
|
||||||
|
rewrite a loop
|
||||||
|
|
||||||
2003-04-01 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2003-04-01 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* text2.C (redoParagraphs): rewrite (with help from Alfredo) for
|
* text2.C (redoParagraphs): rewrite (with help from Alfredo) for
|
||||||
|
64
src/text2.C
64
src/text2.C
@ -683,13 +683,16 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
|||||||
|
|
||||||
int y = cur.y() - tmprit->baseline();
|
int y = cur.y() - tmprit->baseline();
|
||||||
|
|
||||||
Paragraph * first_phys_par = 0;
|
Paragraph * first_phys_par;
|
||||||
if (tmprit == rows().begin()) {
|
if (tmprit == rows().begin()) {
|
||||||
// a trick/hack for UNDO
|
// A trick/hack for UNDO.
|
||||||
// This is needed because in an UNDO/REDO we could have changed
|
// This is needed because in an UNDO/REDO we could have
|
||||||
// the ownerParagrah() so the paragraph inside the row is NOT
|
// changed the ownerParagrah() so the paragraph inside
|
||||||
// my really first par anymore. Got it Lars ;) (Jug 20011206)
|
// the row is NOT my really first par anymore.
|
||||||
|
// Got it Lars ;) (Jug 20011206)
|
||||||
first_phys_par = ownerParagraph();
|
first_phys_par = ownerParagraph();
|
||||||
|
#warning FIXME
|
||||||
|
// In here prevrit could be set to rows().end(). (Lgb)
|
||||||
} else {
|
} else {
|
||||||
first_phys_par = tmprit->par();
|
first_phys_par = tmprit->par();
|
||||||
while (tmprit != rows().begin()
|
while (tmprit != rows().begin()
|
||||||
@ -698,37 +701,31 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
|||||||
--tmprit;
|
--tmprit;
|
||||||
y -= tmprit->height();
|
y -= tmprit->height();
|
||||||
}
|
}
|
||||||
|
#warning FIXME
|
||||||
|
// Is it possible to put the prevrit setting in here? (Lgb)
|
||||||
}
|
}
|
||||||
|
|
||||||
RowList::iterator prevrit;
|
RowList::iterator prevrit;
|
||||||
|
bool good_prevrit = false;
|
||||||
|
#warning FIXME
|
||||||
|
// It seems to mee that good_prevrit is not needed if we let
|
||||||
|
// a bad prevrit have the value rows().end() (Lgb)
|
||||||
if (tmprit != rows().begin()) {
|
if (tmprit != rows().begin()) {
|
||||||
prevrit = boost::prior(tmprit);
|
prevrit = boost::prior(tmprit);
|
||||||
} else {
|
good_prevrit = true;
|
||||||
prevrit = tmprit;
|
|
||||||
y = prevrit ->height();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove it
|
// remove it
|
||||||
Paragraph * tmppar = 0;
|
while (tmprit != rows().end() && tmprit->par() != endpar) {
|
||||||
if (boost::next(tmprit) != rows().end())
|
RowList::iterator tmprit2 = tmprit++;
|
||||||
tmppar = boost::next(tmprit)->par();
|
removeRow(tmprit2);
|
||||||
while (boost::next(tmprit) != rows().end() && tmppar != endpar) {
|
|
||||||
removeRow(boost::next(tmprit));
|
|
||||||
if (boost::next(tmprit) != rows().end()) {
|
|
||||||
tmppar = boost::next(tmprit)->par();
|
|
||||||
} else {
|
|
||||||
tmppar = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the first one
|
|
||||||
RowList::iterator tmprit2 = tmprit; /* this is because tmprow->previous()
|
|
||||||
can be 0 */
|
|
||||||
++tmprit;
|
|
||||||
removeRow(tmprit2);
|
|
||||||
|
|
||||||
// Reinsert the paragraphs.
|
// Reinsert the paragraphs.
|
||||||
tmppar = first_phys_par;
|
Paragraph * tmppar = first_phys_par;
|
||||||
|
#warning FIXME
|
||||||
|
// See if this loop can be rewritten as a while loop instead.
|
||||||
|
// That should also make the code a bit easier to read. (Lgb)
|
||||||
do {
|
do {
|
||||||
if (tmppar) {
|
if (tmppar) {
|
||||||
insertParagraph(tmppar, tmprit);
|
insertParagraph(tmppar, tmprit);
|
||||||
@ -740,11 +737,18 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
|
|||||||
}
|
}
|
||||||
} while (tmppar && tmppar != endpar);
|
} while (tmppar && tmppar != endpar);
|
||||||
|
|
||||||
setHeightOfRow(prevrit);
|
#warning FIXME
|
||||||
const_cast<LyXText *>(this)->postPaint(y - prevrit->height());
|
// If the above changes are done, then we can compare prevrit
|
||||||
|
// with rows().end() here. (Lgb)
|
||||||
if (tmprit != rows().end() && boost::next(tmprit) != rows().end())
|
if (good_prevrit) {
|
||||||
setHeightOfRow(boost::next(tmprit));
|
setHeightOfRow(prevrit);
|
||||||
|
const_cast<LyXText *>(this)->postPaint(y - prevrit->height());
|
||||||
|
} else {
|
||||||
|
setHeightOfRow(rows().begin());
|
||||||
|
const_cast<LyXText *>(this)->postPaint(0);
|
||||||
|
}
|
||||||
|
if (tmprit != rows().end())
|
||||||
|
setHeightOfRow(tmprit);
|
||||||
updateCounters();
|
updateCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user