]> git.lyx.org Git - features.git/commitdiff
The rowlist1 patch
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 29 Mar 2003 19:29:30 +0000 (19:29 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 29 Mar 2003 19:29:30 +0000 (19:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6644 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtext.h
src/text.C
src/text2.C

index 80536e5349dee4f356b4c803e66e10f682e80bfe..63594586d63e45846cdc7a5e62df5b88cfc0998d 100644 (file)
@@ -1,3 +1,17 @@
+2003-03-29  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * text2.C (init): use rowlist_.end() and not 0.
+       (insertRow): change to take a RowList::iterator as arg, adjust
+       for this.
+       (insertParagraph): change to take a RowList::iterator as arg,
+       adjust for this.
+       (redoParagraphs): remove some debug msgs.
+
+       * text.C (appendParagraph): change to take a RowList::iterator
+       arg, adjust for this.
+       (breakAgain): add an assert
+       (breakAgainOneRow): ditto
+
 2003-03-29  John Levon  <levon@movementarian.org>
 
        * text2.C: do not clear selection after inc/decDepth
@@ -64,7 +78,7 @@
 
        * lyxfunc.C: remove a couple of silly questions,
        use Alert::prompt
-       
+
 2003-03-28  John Levon  <levon@movementarian.org>
 
        * text2.C: fix bug 974 (End on empty par)
@@ -74,7 +88,7 @@
        * BufferView_pimpl.C:
        * LyXAction.C:
        * lfuns.h: remove do-nothing math greek lfuns
+
 2003-03-27  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * lyxgluelength.h (isValidGlueLength): add default arg on
index 5a4f8efc51c26cf05d9b648de8698465b2df4f38..beddb960e5110511393471eda4c32e9637bd5e95 100644 (file)
@@ -510,8 +510,9 @@ private:
 
        /** inserts a new row behind the specified row, increments
            the touched counters */
-       void insertRow(Row * row, Paragraph * par, lyx::pos_type pos);
-
+       RowList::iterator
+       insertRow(RowList::iterator rowit,
+                 Paragraph * par, lyx::pos_type pos);
        /// removes the row and reset the touched counters
        void removeRow(Row * row);
 
@@ -519,11 +520,11 @@ private:
        void removeParagraph(Row * row);
 
        /// insert the specified paragraph behind the specified row
-       void insertParagraph(Paragraph * par, Row * row);
+       void insertParagraph(Paragraph * par, RowList::iterator rowit);
 
        /** appends  the implizit specified paragraph behind the specified row,
         * start at the implizit given position */
-       void appendParagraph(Row * row);
+       void appendParagraph(RowList::iterator rowit);
 
        ///
        void breakAgain(Row * row);
index 396ca0e08c624e60a88964c65e89f749cc2de263..d615e7e5ad47206bf2b35e999f8998bdedc1ae99 100644 (file)
@@ -1312,20 +1312,21 @@ void LyXText::setHeightOfRow(Row * row)
 
 // Appends the implicit specified paragraph before the specified row,
 // start at the implicit given position
-void LyXText::appendParagraph(Row * row)
+void LyXText::appendParagraph(RowList::iterator rowit)
 {
-       pos_type const last = row->par()->size();
+       lyx::Assert(rowit != rowlist_.end());
+
+       pos_type const last = rowit->par()->size();
        bool done = false;
 
        do {
-               pos_type z = rowBreakPoint(*row);
+               pos_type z = rowBreakPoint(*rowit);
 
-               Row * tmprow = row;
+               RowList::iterator tmprow = rowit;
 
                if (z < last) {
                        ++z;
-                       insertRow(row, row->par(), z);
-                       row = row->next();
+                       rowit = insertRow(rowit, rowit->par(), z);
                } else {
                        done = true;
                }
@@ -1334,7 +1335,7 @@ void LyXText::appendParagraph(Row * row)
                // fixed fill setting now by calling inset->update() in
                // SingleWidth when needed!
                tmprow->fill(fill(*tmprow, workWidth()));
-               setHeightOfRow(tmprow);
+               setHeightOfRow(&*tmprow);
 
        } while (!done);
 }
@@ -1342,6 +1343,8 @@ void LyXText::appendParagraph(Row * row)
 
 void LyXText::breakAgain(Row * row)
 {
+       lyx::Assert(row);
+
        bool not_ready = true;
 
        do  {
@@ -1387,6 +1390,8 @@ void LyXText::breakAgain(Row * row)
 // this is just a little changed version of break again
 void LyXText::breakAgainOneRow(Row * row)
 {
+       lyx::Assert(row);
+
        pos_type z = rowBreakPoint(*row);
        Row * tmprow = row;
 
index 9774dce7a31fdd1ef55205b9d41501b0bf78c154..bb9dba2a673d93b9c9eb0b24bc90807b6868093f 100644 (file)
@@ -88,7 +88,7 @@ void LyXText::init(BufferView * bview, bool reinit)
 
        while (par) {
                if (rowlist_.empty())
-                       insertParagraph(par, 0);
+                       insertParagraph(par, rowlist_.end());
                else
                        insertParagraph(par, lastRow());
                par = par->next();
@@ -263,18 +263,18 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
 
 // inserts a new row before the specified row, increments
 // the touched counters
-void LyXText::insertRow(Row * row, Paragraph * par,
-                       pos_type pos)
+RowList::iterator
+ LyXText::insertRow(RowList::iterator rowit, Paragraph * par,
+                   pos_type pos)
 {
        Row * tmprow = new Row;
        tmprow->par(par);
        tmprow->pos(pos);
 
-       if (!row) {
-               rowlist_.insert(rowlist_.begin(), tmprow);
-       } else {
-               rowlist_.insert(row->next(), tmprow);
-       }
+       if (rowit == rowlist_.end())
+               return rowlist_.insert(rowlist_.begin(), tmprow);
+       else
+               return rowlist_.insert(boost::next(rowit), tmprow);
 }
 
 
@@ -326,17 +326,13 @@ void LyXText::removeParagraph(Row * row)
 }
 
 
-void LyXText::insertParagraph(Paragraph * par, Row * row)
+void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit)
 {
        // insert a new row, starting at position 0
-       insertRow(row, par, 0);
+       RowList::iterator rit = insertRow(rowit, par, 0);
 
        // and now append the whole paragraph before the new row
-       if (!row) {
-               appendParagraph(firstRow());
-       } else {
-               appendParagraph(row->next());
-       }
+       appendParagraph(rit);
 }
 
 
@@ -715,11 +711,8 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
                // the ownerParagrah() so the paragraph inside the row is NOT
                // my really first par anymore. Got it Lars ;) (Jug 20011206)
                first_phys_par = ownerParagraph();
-               lyxerr << "ownerParagraph" << endl;
-
        } else {
                first_phys_par = tmprow->par();
-               lyxerr << "tmprow->par()" << endl;
 
                // Find first row of this paragraph.
                while (tmprow->previous()
@@ -756,6 +749,7 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
        do {
                if (tmppar) {
                        insertParagraph(tmppar, tmprow);
+
                        if (!tmprow) {
                                tmprow = firstRow();
                        }