]> git.lyx.org Git - features.git/commitdiff
move getParFromID to Buffer
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 9 Jul 2001 09:16:00 +0000 (09:16 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 9 Jul 2001 09:16:00 +0000 (09:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2207 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/BufferView2.C
src/BufferView_pimpl.C
src/ChangeLog
src/buffer.C
src/buffer.h
src/insets/insetcollapsable.C
src/insets/insettabular.C
src/insets/insettext.C
src/lyxfunc.C
src/lyxtext.h
src/paragraph_pimpl.C
src/text2.C
src/undo_funcs.C

index d6f99fcef760ac2893c12bef40d954cecf9255f8..dc33aa57271926d9148429ab4dceaeb53313d72d 100644 (file)
@@ -156,7 +156,7 @@ void BufferView::insertErrors(TeXErrors & terr)
                        texrowpar = text->firstParagraph();
                        tmppos = 0;
                } else {
-                       texrowpar = text->getParFromID(tmpid);
+                       texrowpar = buffer()->getParFromID(tmpid);
                }
 
                if (texrowpar == 0)
@@ -185,7 +185,7 @@ void BufferView::setCursorFromRow(int row)
                texrowpar = text->firstParagraph();
                tmppos = 0;
        } else {
-               texrowpar = text->getParFromID(tmpid);
+               texrowpar = buffer()->getParFromID(tmpid);
        }
        text->setCursor(this, texrowpar, tmppos);
 }
index b15dd9ad75811a2349fbabd7d216dc5e1312ba70..beae2eacb5bfef6ee15572ee5c09cdaa47d30135 100644 (file)
@@ -1149,7 +1149,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
                if (b != 0 ) buffer(b);
        }
 
-       Paragraph * par = bv_->text->getParFromID(saved_positions[i].par_id);
+       Paragraph * par = buffer_->getParFromID(saved_positions[i].par_id);
        if (!par)
                return;
 
index e53a39a1867e1469655ec3554bd8227369218016..782f86953065179df0a821a174b9a3d72755c025 100644 (file)
@@ -1,3 +1,17 @@
+2001-07-09  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * text2.C (getParFromID): removed
+
+       * buffer.C (getParFromID): new method moved form lyxtext.
+       * BufferView2.C (insertErrors): adjust
+       (setCursorFromRow): adjust
+       * BufferView_pimpl.C (restorePosition): adjust
+       * lyxfunc.C (Dispatch): adjust
+       * undo_funcs.C (textUndo): adjust
+       (textRedo): adjust
+       (textHandleUndo): adjust
+       (textHandleUndo): adjust
+
 2001-07-08  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * buffer.C: up' the LYX_FORMAT
index f2dcf5d428ec501ef554bd548be559c30dfc38fa..7f9ab8ccd0b72317916f89af6e256b8812d22f6e 100644 (file)
@@ -3689,3 +3689,21 @@ Inset * Buffer::getInsetFromID(int id_arg) const
        }
        return 0;
 }
+
+
+Paragraph * Buffer::getParFromID(int id) const
+{
+       if (id < 0) return 0;
+       Paragraph * par = paragraph;
+       while (par) {
+               if (par->id() == id) {
+                       return par;
+               }
+               Paragraph * tmp = par->getParFromID(id);
+               if (tmp) {
+                       return tmp;
+               }
+               par = par->next();
+       }
+       return 0;
+}
index bf384d461517fca035c69ae7b0e972744fefa302..dedb17f273e22aae87cb9c14ff921af56a322edf 100644 (file)
@@ -128,6 +128,8 @@ public:
        void insertErtContents(Paragraph * par, int & pos,
                               LyXFont const & font,
                               bool set_inactive = true);
+       ///
+       Paragraph * getParFromID(int id) const;
 private:
        /// Parse a single inset.
        void readInset(LyXLex &, Paragraph *& par, int & pos, LyXFont &);
index 8f58e1435ed622cfd89e8ebcb5ab94ac3579b886..96b4b2976823a6e89fa7c32571f8bcd126513a63 100644 (file)
@@ -498,21 +498,25 @@ int InsetCollapsable::scroll(bool recursive) const
        return sx;
 }
 
+
 Paragraph * InsetCollapsable::getParFromID(int id) const
 {
        return inset.getParFromID(id);
 }
 
+
 Paragraph * InsetCollapsable::firstParagraph() const
 {
        return inset.firstParagraph();
 }
 
+
 LyXCursor const & InsetCollapsable::cursor(BufferView * bv) const
 {
        return inset.cursor(bv);
 }
 
+
 Inset * InsetCollapsable::getInsetFromID(int id_arg) const
 {
        if (id_arg == id())
index a343e41cd93c52344afd1a701967aa38b7698883..2fda1bfe29ac462a5a42d18c1f5abe5a619a7bfd 100644 (file)
@@ -2392,8 +2392,8 @@ void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol)
 Paragraph * InsetTabular::getParFromID(int id) const
 {
        Paragraph * result;
-       for(int i=0; i < tabular->rows(); ++i) {
-               for(int j=0; j < tabular->columns(); ++j) {
+       for(int i = 0; i < tabular->rows(); ++i) {
+               for(int j = 0; j < tabular->columns(); ++j) {
                        if ((result = tabular->GetCellInset(i, j)->getParFromID(id)))
                                return result;
                }
index 58af552d6466e49a9053320ea8e2b4c4c89f02bd..5b0e3aa863f7683b532d22f7a61ac554898e859b 100644 (file)
@@ -1826,6 +1826,7 @@ void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
        need_update = FULL;
 }
 
+
 Paragraph * InsetText::getParFromID(int id) const
 {
        Paragraph * result = par;
@@ -1838,6 +1839,7 @@ Paragraph * InsetText::getParFromID(int id) const
        return result;
 }
 
+
 Paragraph * InsetText::firstParagraph() const
 {
        Paragraph * result;
@@ -1847,6 +1849,7 @@ Paragraph * InsetText::firstParagraph() const
        return par;
 }
 
+
 LyXCursor const & InsetText::cursor(BufferView * bv) const
 {
                if (the_locking_inset)
@@ -1854,11 +1857,13 @@ LyXCursor const & InsetText::cursor(BufferView * bv) const
                return getLyXText(bv)->cursor;
 }
 
+
 Paragraph * InsetText::paragraph() const
 {
        return par;
 }
 
+
 void InsetText::paragraph(Paragraph * p)
 {
        par = p;
@@ -1873,6 +1878,7 @@ void InsetText::paragraph(Paragraph * p)
        need_update |= INIT;
 }
 
+
 Inset * InsetText::getInsetFromID(int id_arg) const
 {
        if (id_arg == id())
index b4a1af2178517da99b48776c04bb8ba77ceeaa47..00feadb0650c5ed8621b1338e8e2b03e95fc50cd 100644 (file)
@@ -1326,7 +1326,7 @@ string const LyXFunc::Dispatch(int ac,
 
                int id;
                istr >> id;
-               Paragraph * par = TEXT()->getParFromID(id);
+               Paragraph * par = owner->buffer()->getParFromID(id);
                if (par == 0) {
                        lyxerr[Debug::INFO] << "No matching paragraph found! ["
                                            << id << "]" << std::endl;
index deeb79729d8692e3d52056004d05979da1c6355a..e5f4275df900bf80d6a7ae09cb0ecc5b0929ffcc 100644 (file)
@@ -442,9 +442,6 @@ public:
        ///
        int numberOfCell(Paragraph * par,
                         Paragraph::size_type pos) const;
-       ///
-       Paragraph * getParFromID(int id) const;
-
        ///
        void removeTableRow(LyXCursor & cursor) const;
        ///
index 56b440f618b31d3412fca212c54eab67abebfcb2..0963a4f1246e4b247b7d05872c3874c3f86a4c80 100644 (file)
@@ -546,11 +546,10 @@ Paragraph * Paragraph::Pimpl::TeXDeeper(Buffer const * buf,
 
 Paragraph * Paragraph::Pimpl::getParFromID(int id) const
 {
+       InsetList::const_iterator cit = owner_->insetlist.begin();
        InsetList::const_iterator lend = owner_->insetlist.end();
        Paragraph * result;
-       for (InsetList::const_iterator cit = owner_->insetlist.begin();
-            cit != lend; ++cit)
-       {
+       for (; cit != lend; ++cit) {
                if ((result = cit->inset->getParFromID(id)))
                        return result;
        }
index 575405f685f1d7dd8e8f215caed1b09b457759ab..70d560cc6d8d32e6f41d28f4ddeb0aa4808a3300 100644 (file)
@@ -2402,20 +2402,6 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
 }
 
 
-Paragraph * LyXText::getParFromID(int id) const
-{
-       if (id < 0)
-               return 0;
-       Paragraph * result = firstParagraph();
-       Paragraph * ires = 0;
-       while (result && result->id() != id) {
-               if ((ires = result->getParFromID(id)))
-                       return ires;
-               result = result->next();
-       }
-       return result;
-}
-
 void LyXText::toggleAppendix(BufferView * bview)
 {
        Paragraph * par = cursor.par();
@@ -2459,7 +2445,7 @@ Paragraph * LyXText::ownerParagraph(Paragraph * p) const
 
 Paragraph * LyXText::ownerParagraph(int id, Paragraph * p) const
 {
-       Paragraph * op = getParFromID(id);
+       Paragraph * op = bv_owner->buffer()->getParFromID(id);
        if (op && op->InInset()) {
                static_cast<InsetText *>(op->InInset())->paragraph(p);
        } else {
index d1b0f2ab48425083386cc9f37cbdc96c243e8e24..0288a053c56e54f9d31c7b3405df31b9e92e7d7c 100644 (file)
@@ -32,13 +32,13 @@ bool textUndo(BufferView * bv)
        if (undo) {
                finishUndo();
                if (!undo_frozen) {
-                       Paragraph * first = bv->text->getParFromID(undo->number_of_before_par);
+                       Paragraph * first = bv->buffer()->getParFromID(undo->number_of_before_par);
                        if (!first)
                                first = firstUndoParagraph(bv, undo->number_of_inset_id);
                        if (first) {
                                bv->buffer()->redostack.push(
                                        createUndo(bv, undo->kind, first,
-                                                          bv->text->getParFromID(undo->number_of_behind_par)));
+                                                          bv->buffer()->getParFromID(undo->number_of_behind_par)));
                        }
                }
        }
@@ -53,13 +53,13 @@ bool textRedo(BufferView * bv)
        if (undo) {
                finishUndo();
                if (!undo_frozen) {
-                       Paragraph * first = bv->text->getParFromID(undo->number_of_before_par);
+                       Paragraph * first = bv->buffer()->getParFromID(undo->number_of_before_par);
                        if (!first)
                                first = firstUndoParagraph(bv, undo->number_of_inset_id);
                        if (first) {
                                bv->buffer()->undostack.push(
                                        createUndo(bv, undo->kind, first,
-                                                  bv->text->getParFromID(undo->number_of_behind_par)));
+                                                  bv->buffer()->getParFromID(undo->number_of_behind_par)));
                        }
                }
        }
@@ -73,9 +73,9 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
        bool result = false;
        if (undo) {
                Paragraph * before =
-                       bv->text->getParFromID(undo->number_of_before_par); 
+                       bv->buffer()->getParFromID(undo->number_of_before_par); 
                Paragraph * behind =
-                       bv->text->getParFromID(undo->number_of_behind_par); 
+                       bv->buffer()->getParFromID(undo->number_of_behind_par); 
                Paragraph * tmppar;
                Paragraph * tmppar2;
                Paragraph * endpar;
@@ -158,7 +158,7 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
                } else
                        endpar = behind;
     
-               tmppar = bv->text->getParFromID(undo->number_of_cursor_par);
+               tmppar = bv->buffer()->getParFromID(undo->number_of_cursor_par);
                UpdatableInset* it = static_cast<UpdatableInset*>(tmppar3->InInset());
                if (it) {
                        it->getLyXText(bv)->redoParagraphs(bv, it->getLyXText(bv)->cursor,