]> git.lyx.org Git - features.git/commitdiff
parlist-7-a.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 10 Apr 2003 21:07:55 +0000 (21:07 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 10 Apr 2003 21:07:55 +0000 (21:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6773 a592a061-630c-0410-9148-cb99ea01b6c8

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

index e505b288bbc054f93cb94b4d65d87131e053d49e..32c406952bff6f153f5c8e3af7fe745f4124dc02 100644 (file)
@@ -1,5 +1,14 @@
 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.
        (realizeFont): take a ParagraphList::iterator as arg.
        (getLayoutFont): ditto
index 6dd09b6237466e047141c816acf3f5224e928726..3d45e28352658f8e5f345eb12be5d0588ec1d15b 100644 (file)
@@ -125,10 +125,11 @@ public:
        /** set layout over selection and make a total rebreak of
          those paragraphs
          */
-       Paragraph * setLayout(LyXCursor & actual_cursor,
-                             LyXCursor & selection_start,
-                             LyXCursor & selection_end,
-                             string const & layout);
+       ParagraphList::iterator
+       setLayout(LyXCursor & actual_cursor,
+                 LyXCursor & selection_start,
+                 LyXCursor & selection_end,
+                 string const & layout);
        ///
        void setLayout(string const & layout);
 
@@ -154,7 +155,7 @@ public:
          This function is needed after SetLayout and SetFont etc.
          */
        void redoParagraphs(LyXCursor const & cursor,
-                           Paragraph const * end_par);
+                           ParagraphList::iterator endpit);
        ///
        void redoParagraph();
 
@@ -249,7 +250,7 @@ public:
         of the row
         */
        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 {
                return rowlist_;
@@ -469,7 +470,7 @@ public:
        /// returns false if inset wasn't found
        bool updateInset(Inset *);
        ///
-       void checkParagraph(Paragraph * par, lyx::pos_type pos);
+       void checkParagraph(ParagraphList::iterator pit, lyx::pos_type pos);
        ///
        int workWidth() const;
        ///
@@ -515,7 +516,8 @@ private:
        void removeParagraph(RowList::iterator rit);
 
        /// 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,
         * start at the implizit given position */
@@ -582,7 +584,7 @@ public:
 
 private:
        ///
-       void setCounter(Buffer const *, Paragraph * par);
+       void setCounter(Buffer const *, ParagraphList::iterator pit);
        ///
        void deleteWordForward();
        ///
index a85c76515c4ce8d87349da2d2394fab1d892bab9..77fb8a7693868d0d9dec02c323f7831a2c5e1fdd 100644 (file)
@@ -2713,7 +2713,7 @@ void LyXText::backspace()
 
 // returns pointer to a specified row
 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;
 
@@ -2723,7 +2723,7 @@ LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
        // find the first row of the specified paragraph
        RowList::iterator rit = rowlist_.begin();
        RowList::iterator end = rowlist_.end();
-       while (boost::next(rit) != end && rit->par() != par) {
+       while (boost::next(rit) != end && rit->par() != pit) {
                y += rit->height();
                ++rit;
        }
@@ -2731,7 +2731,7 @@ LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
        // now find the wanted row
        while (rit->pos() < pos
               && boost::next(rit) != end
-              && boost::next(rit)->par() == par
+              && boost::next(rit)->par() == pit
               && boost::next(rit)->pos() <= pos) {
                y += rit->height();
                ++rit;
@@ -2749,7 +2749,9 @@ RowList::iterator LyXText::getRowNearY(int & y) const
        RowList::iterator rit = rowlist_.begin();
        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();
                ++rit;
        }
index 764fc073dc7aec7806ad26e40055ae4b631825fe..ed770d93b03021b335278eb59ea6fb3bf95f63e2 100644 (file)
@@ -311,11 +311,11 @@ void LyXText::removeParagraph(RowList::iterator rit)
 }
 
 
-#warning FIXME Convert this to ParagraphList::iterator
-void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit)
+void LyXText::insertParagraph(ParagraphList::iterator pit,
+                             RowList::iterator rowit)
 {
        // insert a new row, starting at position 0
-       Row newrow(par, 0);
+       Row newrow(pit, 0);
        RowList::iterator rit = rowlist_.insert(rowit, newrow);
 
        // and now append the whole paragraph before the new row
@@ -384,9 +384,10 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const & buf,
 }
 
 
-Paragraph * LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
-                              LyXCursor & send_cur,
-                              string const & layout)
+ParagraphList::iterator
+LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
+                  LyXCursor & send_cur,
+                  string const & layout)
 {
        Paragraph * endpar = send_cur.par()->next();
        Paragraph * undoendpar = endpar;
@@ -442,9 +443,9 @@ void LyXText::setLayout(string const & layout)
                selection.start = cursor;  // dummy selection
                selection.end = cursor;
        }
-       Paragraph * endpar = setLayout(cursor, selection.start,
-                                      selection.end, layout);
-       redoParagraphs(selection.start, endpar);
+       ParagraphList::iterator endpit = setLayout(cursor, selection.start,
+                                                  selection.end, layout);
+       redoParagraphs(selection.start, endpit);
 
        // we have to reset the selection, because the
        // geometry could have changed
@@ -651,10 +652,9 @@ void LyXText::redoDrawingOfParagraph(LyXCursor const & cur)
 // and the specified par
 // This function is needed after SetLayout and SetFont etc.
 void LyXText::redoParagraphs(LyXCursor const & cur,
-                            Paragraph const * ep)
+                            ParagraphList::iterator endpit)
 {
        RowList::iterator tmprit = cur.row();
-       ParagraphList::iterator endpit(const_cast<Paragraph*>(ep));
        int y = cur.y() - tmprit->baseline();
 
        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
-void LyXText::setCounter(Buffer const * buf, Paragraph * par)
+void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
 {
        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());
-               if (!par->params().appendix() && par->params().startOfAppendix()) {
-                       par->params().appendix(true);
+               pit->params().appendix(boost::prior(pit)->params().appendix());
+               if (!pit->params().appendix() &&
+                   pit->params().startOfAppendix()) {
+                       pit->params().appendix(true);
                        textclass.counters().reset();
                }
-               par->enumdepth = par->previous()->enumdepth;
-               par->itemdepth = par->previous()->itemdepth;
+               pit->enumdepth = boost::prior(pit)->enumdepth;
+               pit->itemdepth = boost::prior(pit)->itemdepth;
        } else {
-               par->params().appendix(par->params().startOfAppendix());
-               par->enumdepth = 0;
-               par->itemdepth = 0;
+               pit->params().appendix(pit->params().startOfAppendix());
+               pit->enumdepth = 0;
+               pit->itemdepth = 0;
        }
 
        /* 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
         *      are always of depth 0
         */
-       if (par->previous()
-           && par->previous()->getDepth() < par->getDepth()
-           && par->previous()->layout()->labeltype == LABEL_COUNTER_ENUMI
-           && par->enumdepth < 3
+       if (pit != ownerParagraphs().begin()
+           && boost::prior(pit)->getDepth() < pit->getDepth()
+           && boost::prior(pit)->layout()->labeltype == LABEL_COUNTER_ENUMI
+           && pit->enumdepth < 3
            && layout->labeltype != LABEL_BIBLIO) {
-               par->enumdepth++;
+               pit->enumdepth++;
        }
 
        // Maybe we have to decrement the enumeration depth, see note above
-       if (par->previous()
-           && par->previous()->getDepth() > par->getDepth()
+       if (pit != ownerParagraphs().begin()
+           && boost::prior(pit)->getDepth() > pit->getDepth()
            && layout->labeltype != LABEL_BIBLIO) {
-               par->enumdepth = par->depthHook(par->getDepth())->enumdepth;
+               pit->enumdepth = pit->depthHook(pit->getDepth())->enumdepth;
        }
 
-       if (!par->params().labelString().empty()) {
-               par->params().labelString(string());
+       if (!pit->params().labelString().empty()) {
+               pit->params().labelString(string());
        }
 
        if (layout->margintype == MARGIN_MANUAL) {
-               if (par->params().labelWidthString().empty()) {
-                       par->setLabelWidthString(layout->labelstring());
+               if (pit->params().labelWidthString().empty()) {
+                       pit->setLabelWidthString(layout->labelstring());
                }
        } else {
-               par->setLabelWidthString(string());
+               pit->setLabelWidthString(string());
        }
 
        // 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());
 
                        // Is there a label? Useful for Chapter layout
-                       if (!par->params().appendix()) {
+                       if (!pit->params().appendix()) {
                                s << layout->labelstring();
                        } else {
                                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.
                        int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER;
-                       if (!par->params().appendix()) {
+                       if (!pit->params().appendix()) {
                                numbertype = "sectioning";
                        } else {
                                numbertype = "appendix";
-                               if (par->isRightToLeftPar(buf->params))
+                               if (pit->isRightToLeftPar(buf->params))
                                        langtype = "hebrew";
                                else
                                        langtype = "latin";
@@ -1135,7 +1136,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
                                .numberLabel(layout->latexname(),
                                             numbertype, langtype, head);
 
-                       par->params().labelString(STRCONV(s.str()));
+                       pit->params().labelString(STRCONV(s.str()));
 
                        // reset enum counters
                        textclass.counters().reset("enum");
@@ -1147,7 +1148,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
                        // (Lgb)
                        string enumcounter("enum");
 
-                       switch (par->enumdepth) {
+                       switch (pit->enumdepth) {
                        case 2:
                                enumcounter += 'i';
                        case 1:
@@ -1167,14 +1168,14 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
 
                        s << textclass.counters()
                                .numberLabel(enumcounter, "enumeration");
-                       par->params().labelString(STRCONV(s.str()));
+                       pit->params().labelString(STRCONV(s.str()));
                }
        } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
                textclass.counters().step("bibitem");
                int number = textclass.counters().value("bibitem");
-               if (par->bibitem()) {
-                       par->bibitem()->setCounter(number);
-                       par->params().labelString(layout->labelstring());
+               if (pit->bibitem()) {
+                       pit->bibitem()->setCounter(number);
+                       pit->params().labelString(layout->labelstring());
                }
                // In biblio should't be following counters but...
        } else {
@@ -1182,18 +1183,19 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
 
                // the caption hack:
                if (layout->labeltype == LABEL_SENSITIVE) {
-                       Paragraph * tmppar = par;
+                       ParagraphList::iterator tmppit = pit;
                        Inset * in = 0;
                        bool isOK = false;
-                       while (tmppar && tmppar->inInset()
+                       while (tmppit != ownerParagraphs().end() &&
+                              tmppit->inInset()
                               // the single '=' is intended below
-                              && (in = tmppar->inInset()->owner())) {
+                              && (in = tmppit->inInset()->owner())) {
                                if (in->lyxCode() == Inset::FLOAT_CODE ||
                                    in->lyxCode() == Inset::WRAP_CODE) {
                                        isOK = true;
                                        break;
                                } else {
-                                       tmppar = in->parOwner();
+                                       tmppit = in->parOwner();
                                }
                        }
 
@@ -1221,13 +1223,13 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par)
                                s = _("Senseless: ");
                        }
                }
-               par->params().labelString(s);
+               pit->params().labelString(s);
 
                // reset the enumeration counter. They are always reset
                // when there is any other layout between
                // Just fall-through between the cases so that all
                // enum counters deeper than enumdepth is also reset.
-               switch (par->enumdepth) {
+               switch (pit->enumdepth) {
                case 0:
                        textclass.counters().reset("enumi");
                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;
 
        int y = 0;
        pos_type z;
-       RowList::iterator row = getRow(par, pos, y);
+       RowList::iterator row = getRow(pit, pos, y);
        RowList::iterator beg = rows().begin();
 
        // 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
-       if (par->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
-               tmpcursor.par(par);
+       if (pit->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+               tmpcursor.par(pit);
                tmpcursor.row(row);
                tmpcursor.y(y);
                tmpcursor.x(0);
@@ -1667,7 +1669,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
 
        // get the cursor y position in text
        int y = 0;
-       RowList::iterator row = getRow(&*pit, pos, y);
+       RowList::iterator row = getRow(pit, pos, y);
        RowList::iterator beg = rows().begin();
 
        RowList::iterator old_row = row;
@@ -2270,6 +2272,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                        tmpcursor = cursor;
                        cursor = old_cursor; // that undo can restore the right cursor position
                        Paragraph * endpar = old_cursor.par()->next();
+#warning FIXME This if clause looks very redundant. (Lgb)
                        if (endpar && endpar->getDepth()) {
                                while (endpar && endpar->getDepth()) {
                                        endpar = endpar->next();