parlist-7-a.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6773 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-04-10 21:07:55 +00:00
parent c951809efd
commit 04337321d0
4 changed files with 84 additions and 68 deletions

View File

@ -1,5 +1,14 @@
2003-04-10 Lars Gullik Bjønnes <larsbj@gullik.net> 2003-04-10 Lars Gullik Bjønnes <larsbj@gullik.net>
* text2.C (insertParagraph): make it take ParagraphList::iterator
as arg.
(setLayout): make it return ParagraphList::iterator
(redoParagraphs): ditto
(setCounter): ditto
(checkParagraph): ditto
* text.C (getRow): make getrow take ParagraphList::iterator as arg
* text2.C: adjust several funcs. * text2.C: adjust several funcs.
(realizeFont): take a ParagraphList::iterator as arg. (realizeFont): take a ParagraphList::iterator as arg.
(getLayoutFont): ditto (getLayoutFont): ditto

View File

@ -125,7 +125,8 @@ public:
/** set layout over selection and make a total rebreak of /** set layout over selection and make a total rebreak of
those paragraphs those paragraphs
*/ */
Paragraph * setLayout(LyXCursor & actual_cursor, ParagraphList::iterator
setLayout(LyXCursor & actual_cursor,
LyXCursor & selection_start, LyXCursor & selection_start,
LyXCursor & selection_end, LyXCursor & selection_end,
string const & layout); string const & layout);
@ -154,7 +155,7 @@ public:
This function is needed after SetLayout and SetFont etc. This function is needed after SetLayout and SetFont etc.
*/ */
void redoParagraphs(LyXCursor const & cursor, void redoParagraphs(LyXCursor const & cursor,
Paragraph const * end_par); ParagraphList::iterator endpit);
/// ///
void redoParagraph(); void redoParagraph();
@ -249,7 +250,7 @@ public:
of the row of the row
*/ */
RowList::iterator RowList::iterator
getRow(Paragraph * par, lyx::pos_type pos, int & y) const; getRow(ParagraphList::iterator pit, lyx::pos_type pos, int & y) const;
RowList & rows() const { RowList & rows() const {
return rowlist_; return rowlist_;
@ -469,7 +470,7 @@ public:
/// returns false if inset wasn't found /// returns false if inset wasn't found
bool updateInset(Inset *); bool updateInset(Inset *);
/// ///
void checkParagraph(Paragraph * par, lyx::pos_type pos); void checkParagraph(ParagraphList::iterator pit, lyx::pos_type pos);
/// ///
int workWidth() const; int workWidth() const;
/// ///
@ -515,7 +516,8 @@ private:
void removeParagraph(RowList::iterator rit); void removeParagraph(RowList::iterator rit);
/// insert the specified paragraph behind the specified row /// insert the specified paragraph behind the specified row
void insertParagraph(Paragraph * par, RowList::iterator rowit); void insertParagraph(ParagraphList::iterator pit,
RowList::iterator rowit);
/** appends the implizit specified paragraph behind the specified row, /** appends the implizit specified paragraph behind the specified row,
* start at the implizit given position */ * start at the implizit given position */
@ -582,7 +584,7 @@ public:
private: private:
/// ///
void setCounter(Buffer const *, Paragraph * par); void setCounter(Buffer const *, ParagraphList::iterator pit);
/// ///
void deleteWordForward(); void deleteWordForward();
/// ///

View File

@ -2713,7 +2713,7 @@ void LyXText::backspace()
// returns pointer to a specified row // returns pointer to a specified row
RowList::iterator RowList::iterator
LyXText::getRow(Paragraph * par, pos_type pos, int & y) const LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
{ {
y = 0; y = 0;
@ -2723,7 +2723,7 @@ LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
// find the first row of the specified paragraph // find the first row of the specified paragraph
RowList::iterator rit = rowlist_.begin(); RowList::iterator rit = rowlist_.begin();
RowList::iterator end = rowlist_.end(); RowList::iterator end = rowlist_.end();
while (boost::next(rit) != end && rit->par() != par) { while (boost::next(rit) != end && rit->par() != pit) {
y += rit->height(); y += rit->height();
++rit; ++rit;
} }
@ -2731,7 +2731,7 @@ LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
// now find the wanted row // now find the wanted row
while (rit->pos() < pos while (rit->pos() < pos
&& boost::next(rit) != end && boost::next(rit) != end
&& boost::next(rit)->par() == par && boost::next(rit)->par() == pit
&& boost::next(rit)->pos() <= pos) { && boost::next(rit)->pos() <= pos) {
y += rit->height(); y += rit->height();
++rit; ++rit;
@ -2749,7 +2749,9 @@ RowList::iterator LyXText::getRowNearY(int & y) const
RowList::iterator rit = rowlist_.begin(); RowList::iterator rit = rowlist_.begin();
RowList::iterator end = rowlist_.end(); RowList::iterator end = rowlist_.end();
while (rit != end && boost::next(rit) != end && tmpy + rit->height() <= y) { while (rit != end &&
boost::next(rit) != end &&
tmpy + rit->height() <= y) {
tmpy += rit->height(); tmpy += rit->height();
++rit; ++rit;
} }

View File

@ -311,11 +311,11 @@ void LyXText::removeParagraph(RowList::iterator rit)
} }
#warning FIXME Convert this to ParagraphList::iterator void LyXText::insertParagraph(ParagraphList::iterator pit,
void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit) RowList::iterator rowit)
{ {
// insert a new row, starting at position 0 // insert a new row, starting at position 0
Row newrow(par, 0); Row newrow(pit, 0);
RowList::iterator rit = rowlist_.insert(rowit, newrow); RowList::iterator rit = rowlist_.insert(rowit, newrow);
// and now append the whole paragraph before the new row // and now append the whole paragraph before the new row
@ -384,7 +384,8 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const & buf,
} }
Paragraph * LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur, ParagraphList::iterator
LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
LyXCursor & send_cur, LyXCursor & send_cur,
string const & layout) string const & layout)
{ {
@ -442,9 +443,9 @@ void LyXText::setLayout(string const & layout)
selection.start = cursor; // dummy selection selection.start = cursor; // dummy selection
selection.end = cursor; selection.end = cursor;
} }
Paragraph * endpar = setLayout(cursor, selection.start, ParagraphList::iterator endpit = setLayout(cursor, selection.start,
selection.end, layout); selection.end, layout);
redoParagraphs(selection.start, endpar); redoParagraphs(selection.start, endpit);
// we have to reset the selection, because the // we have to reset the selection, because the
// geometry could have changed // geometry could have changed
@ -651,10 +652,9 @@ void LyXText::redoDrawingOfParagraph(LyXCursor const & cur)
// and the specified par // and the specified par
// This function is needed after SetLayout and SetFont etc. // This function is needed after SetLayout and SetFont etc.
void LyXText::redoParagraphs(LyXCursor const & cur, void LyXText::redoParagraphs(LyXCursor const & cur,
Paragraph const * ep) ParagraphList::iterator endpit)
{ {
RowList::iterator tmprit = cur.row(); RowList::iterator tmprit = cur.row();
ParagraphList::iterator endpit(const_cast<Paragraph*>(ep));
int y = cur.y() - tmprit->baseline(); int y = cur.y() - tmprit->baseline();
ParagraphList::iterator first_phys_pit; ParagraphList::iterator first_phys_pit;
@ -1046,24 +1046,25 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
// set the counter of a paragraph. This includes the labels // set the counter of a paragraph. This includes the labels
void LyXText::setCounter(Buffer const * buf, Paragraph * par) void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
{ {
LyXTextClass const & textclass = buf->params.getLyXTextClass(); LyXTextClass const & textclass = buf->params.getLyXTextClass();
LyXLayout_ptr const & layout = par->layout(); LyXLayout_ptr const & layout = pit->layout();
if (par->previous()) { if (pit != ownerParagraphs().begin()) {
par->params().appendix(par->previous()->params().appendix()); pit->params().appendix(boost::prior(pit)->params().appendix());
if (!par->params().appendix() && par->params().startOfAppendix()) { if (!pit->params().appendix() &&
par->params().appendix(true); pit->params().startOfAppendix()) {
pit->params().appendix(true);
textclass.counters().reset(); textclass.counters().reset();
} }
par->enumdepth = par->previous()->enumdepth; pit->enumdepth = boost::prior(pit)->enumdepth;
par->itemdepth = par->previous()->itemdepth; pit->itemdepth = boost::prior(pit)->itemdepth;
} else { } else {
par->params().appendix(par->params().startOfAppendix()); pit->params().appendix(pit->params().startOfAppendix());
par->enumdepth = 0; pit->enumdepth = 0;
par->itemdepth = 0; pit->itemdepth = 0;
} }
/* Maybe we have to increment the enumeration depth. /* Maybe we have to increment the enumeration depth.
@ -1073,31 +1074,31 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
* AND, bibliographies can't have their depth changed ie. they * AND, bibliographies can't have their depth changed ie. they
* are always of depth 0 * are always of depth 0
*/ */
if (par->previous() if (pit != ownerParagraphs().begin()
&& par->previous()->getDepth() < par->getDepth() && boost::prior(pit)->getDepth() < pit->getDepth()
&& par->previous()->layout()->labeltype == LABEL_COUNTER_ENUMI && boost::prior(pit)->layout()->labeltype == LABEL_COUNTER_ENUMI
&& par->enumdepth < 3 && pit->enumdepth < 3
&& layout->labeltype != LABEL_BIBLIO) { && layout->labeltype != LABEL_BIBLIO) {
par->enumdepth++; pit->enumdepth++;
} }
// Maybe we have to decrement the enumeration depth, see note above // Maybe we have to decrement the enumeration depth, see note above
if (par->previous() if (pit != ownerParagraphs().begin()
&& par->previous()->getDepth() > par->getDepth() && boost::prior(pit)->getDepth() > pit->getDepth()
&& layout->labeltype != LABEL_BIBLIO) { && layout->labeltype != LABEL_BIBLIO) {
par->enumdepth = par->depthHook(par->getDepth())->enumdepth; pit->enumdepth = pit->depthHook(pit->getDepth())->enumdepth;
} }
if (!par->params().labelString().empty()) { if (!pit->params().labelString().empty()) {
par->params().labelString(string()); pit->params().labelString(string());
} }
if (layout->margintype == MARGIN_MANUAL) { if (layout->margintype == MARGIN_MANUAL) {
if (par->params().labelWidthString().empty()) { if (pit->params().labelWidthString().empty()) {
par->setLabelWidthString(layout->labelstring()); pit->setLabelWidthString(layout->labelstring());
} }
} else { } else {
par->setLabelWidthString(string()); pit->setLabelWidthString(string());
} }
// is it a layout that has an automatic label? // is it a layout that has an automatic label?
@ -1113,7 +1114,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
textclass.counters().step(layout->latexname()); textclass.counters().step(layout->latexname());
// Is there a label? Useful for Chapter layout // Is there a label? Useful for Chapter layout
if (!par->params().appendix()) { if (!pit->params().appendix()) {
s << layout->labelstring(); s << layout->labelstring();
} else { } else {
s << layout->labelstring_appendix(); s << layout->labelstring_appendix();
@ -1121,11 +1122,11 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
// Use of an integer is here less than elegant. For now. // Use of an integer is here less than elegant. For now.
int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER; int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER;
if (!par->params().appendix()) { if (!pit->params().appendix()) {
numbertype = "sectioning"; numbertype = "sectioning";
} else { } else {
numbertype = "appendix"; numbertype = "appendix";
if (par->isRightToLeftPar(buf->params)) if (pit->isRightToLeftPar(buf->params))
langtype = "hebrew"; langtype = "hebrew";
else else
langtype = "latin"; langtype = "latin";
@ -1135,7 +1136,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
.numberLabel(layout->latexname(), .numberLabel(layout->latexname(),
numbertype, langtype, head); numbertype, langtype, head);
par->params().labelString(STRCONV(s.str())); pit->params().labelString(STRCONV(s.str()));
// reset enum counters // reset enum counters
textclass.counters().reset("enum"); textclass.counters().reset("enum");
@ -1147,7 +1148,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
// (Lgb) // (Lgb)
string enumcounter("enum"); string enumcounter("enum");
switch (par->enumdepth) { switch (pit->enumdepth) {
case 2: case 2:
enumcounter += 'i'; enumcounter += 'i';
case 1: case 1:
@ -1167,14 +1168,14 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
s << textclass.counters() s << textclass.counters()
.numberLabel(enumcounter, "enumeration"); .numberLabel(enumcounter, "enumeration");
par->params().labelString(STRCONV(s.str())); pit->params().labelString(STRCONV(s.str()));
} }
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302 } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
textclass.counters().step("bibitem"); textclass.counters().step("bibitem");
int number = textclass.counters().value("bibitem"); int number = textclass.counters().value("bibitem");
if (par->bibitem()) { if (pit->bibitem()) {
par->bibitem()->setCounter(number); pit->bibitem()->setCounter(number);
par->params().labelString(layout->labelstring()); pit->params().labelString(layout->labelstring());
} }
// In biblio should't be following counters but... // In biblio should't be following counters but...
} else { } else {
@ -1182,18 +1183,19 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
// the caption hack: // the caption hack:
if (layout->labeltype == LABEL_SENSITIVE) { if (layout->labeltype == LABEL_SENSITIVE) {
Paragraph * tmppar = par; ParagraphList::iterator tmppit = pit;
Inset * in = 0; Inset * in = 0;
bool isOK = false; bool isOK = false;
while (tmppar && tmppar->inInset() while (tmppit != ownerParagraphs().end() &&
tmppit->inInset()
// the single '=' is intended below // the single '=' is intended below
&& (in = tmppar->inInset()->owner())) { && (in = tmppit->inInset()->owner())) {
if (in->lyxCode() == Inset::FLOAT_CODE || if (in->lyxCode() == Inset::FLOAT_CODE ||
in->lyxCode() == Inset::WRAP_CODE) { in->lyxCode() == Inset::WRAP_CODE) {
isOK = true; isOK = true;
break; break;
} else { } else {
tmppar = in->parOwner(); tmppit = in->parOwner();
} }
} }
@ -1221,13 +1223,13 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
s = _("Senseless: "); s = _("Senseless: ");
} }
} }
par->params().labelString(s); pit->params().labelString(s);
// reset the enumeration counter. They are always reset // reset the enumeration counter. They are always reset
// when there is any other layout between // when there is any other layout between
// Just fall-through between the cases so that all // Just fall-through between the cases so that all
// enum counters deeper than enumdepth is also reset. // enum counters deeper than enumdepth is also reset.
switch (par->enumdepth) { switch (pit->enumdepth) {
case 0: case 0:
textclass.counters().reset("enumi"); textclass.counters().reset("enumi");
case 1: case 1:
@ -1541,13 +1543,13 @@ void LyXText::insertStringAsParagraphs(string const & str)
} }
void LyXText::checkParagraph(Paragraph * par, pos_type pos) void LyXText::checkParagraph(ParagraphList::iterator pit, pos_type pos)
{ {
LyXCursor tmpcursor; LyXCursor tmpcursor;
int y = 0; int y = 0;
pos_type z; pos_type z;
RowList::iterator row = getRow(par, pos, y); RowList::iterator row = getRow(pit, pos, y);
RowList::iterator beg = rows().begin(); RowList::iterator beg = rows().begin();
// is there a break one row above // is there a break one row above
@ -1581,8 +1583,8 @@ void LyXText::checkParagraph(Paragraph * par, pos_type pos)
} }
// check the special right address boxes // check the special right address boxes
if (par->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) { if (pit->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
tmpcursor.par(par); tmpcursor.par(pit);
tmpcursor.row(row); tmpcursor.row(row);
tmpcursor.y(y); tmpcursor.y(y);
tmpcursor.x(0); tmpcursor.x(0);
@ -1667,7 +1669,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
// get the cursor y position in text // get the cursor y position in text
int y = 0; int y = 0;
RowList::iterator row = getRow(&*pit, pos, y); RowList::iterator row = getRow(pit, pos, y);
RowList::iterator beg = rows().begin(); RowList::iterator beg = rows().begin();
RowList::iterator old_row = row; RowList::iterator old_row = row;
@ -2270,6 +2272,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
tmpcursor = cursor; tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position cursor = old_cursor; // that undo can restore the right cursor position
Paragraph * endpar = old_cursor.par()->next(); Paragraph * endpar = old_cursor.par()->next();
#warning FIXME This if clause looks very redundant. (Lgb)
if (endpar && endpar->getDepth()) { if (endpar && endpar->getDepth()) {
while (endpar && endpar->getDepth()) { while (endpar && endpar->getDepth()) {
endpar = endpar->next(); endpar = endpar->next();