... should yield a Paragraph &, not a ParagraphList::iterator.

Patch attached.

Lars?

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.158
diff -u -p -r1.158 BufferView.C
--- BufferView.C        29 May 2003 01:13:15 -0000      1.158
+++ BufferView.C        11 Jun 2003 13:58:59 -0000
@@ -379,7 +379,7 @@ void BufferView::setCursorFromRow(int ro
                texrowpar = text->ownerParagraphs().begin();
                tmppos = 0;
        } else {
-               texrowpar = *buffer()->getParFromID(tmpid);
+               texrowpar = buffer()->getParFromID(tmpid).pit();
        }
        text->setCursor(texrowpar, tmppos);
 }
@@ -645,7 +645,7 @@ bool BufferView::ChangeInsets(Inset::Cod
                        // The test it.size()==1 was needed to prevent crashes.
                        // How to set the cursor corretly when it.size()>1 ??
                        if (it.size() == 1) {
-                               text->setCursorIntern(*it, 0);
+                               text->setCursorIntern(it.pit(), 0);
                                text->redoParagraphs(text->cursor,
                                                     boost::next(text->cursor.par()));
                                text->fullRebreak();
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.374
diff -u -p -r1.374 BufferView_pimpl.C
--- BufferView_pimpl.C  6 Jun 2003 08:06:22 -0000       1.374
+++ BufferView_pimpl.C  11 Jun 2003 13:58:59 -0000
@@ -651,8 +651,8 @@ void BufferView::Pimpl::restorePosition(
        if (par == buffer_->par_iterator_end())
                return;
 
-       bv_->text->setCursor(*par,
-                            min((*par)->size(), saved_positions[i].par_pos));
+       bv_->text->setCursor(par.pit(),
+                            min(par->size(), saved_positions[i].par_pos));
 
        update(BufferView::SELECT);
        if (i > 0)
@@ -861,9 +861,8 @@ void BufferView::Pimpl::trackChanges()
 
        if (!tracking) {
                ParIterator const end = buf->par_iterator_end();
-               for (ParIterator it = buf->par_iterator_begin(); it != end; ++it) {
-                       (*it)->trackChanges();
-               }
+               for (ParIterator it = buf->par_iterator_begin(); it != end; ++it) 
+                       it->trackChanges();
                buf->params.tracking_changes = true;
 
                // we cannot allow undos beyond the freeze point
@@ -881,9 +880,8 @@ void BufferView::Pimpl::trackChanges()
                }
 
                ParIterator const end = buf->par_iterator_end();
-               for (ParIterator it = buf->par_iterator_begin(); it != end; ++it) {
-                       (*it)->untrackChanges();
-               }
+               for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
+                       it->untrackChanges();
                buf->params.tracking_changes = false;
        }
 
Index: CutAndPaste.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v
retrieving revision 1.101
diff -u -p -r1.101 CutAndPaste.C
--- CutAndPaste.C       10 Jun 2003 14:39:41 -0000      1.101
+++ CutAndPaste.C       11 Jun 2003 13:58:59 -0000
@@ -377,25 +377,24 @@ int CutAndPaste::SwitchLayoutsBetweenCla
        LyXTextClass const & tclass2 = textclasslist[c2];
        ParIterator end = ParIterator(pars.end(), pars);
        for (ParIterator it = ParIterator(pars.begin(), pars); it != end; ++it) {
-               Paragraph * par = &*(*it);
-               string const name = par->layout()->name();
+               string const name = it->layout()->name();
                bool hasLayout = tclass2.hasLayout(name);
 
                if (hasLayout)
-                       par->layout(tclass2[name]);
+                       it->layout(tclass2[name]);
                else
-                       par->layout(tclass2.defaultLayout());
+                       it->layout(tclass2.defaultLayout());
 
                if (!hasLayout && name != tclass1.defaultLayoutName()) {
                        ++ret;
                        string const s = bformat(
                                _("Layout had to be changed from\n%1$s to %2$s\n"
                                "because of class conversion from\n%3$s to %4$s"),
-                        name, par->layout()->name(), tclass1.name(), tclass2.name());
+                        name, it->layout()->name(), tclass1.name(), tclass2.name());
                        // To warn the user that something had to be done.
                        errorlist.push_back(ErrorItem("Changed Layout", s,
-                                                     par->id(), 0,
-                                                     par->size()));
+                                                     it->id(), 0,
+                                                     it->size()));
                }
        }
        return ret;
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.481
diff -u -p -r1.481 buffer.C
--- buffer.C    10 Jun 2003 14:39:41 -0000      1.481
+++ buffer.C    11 Jun 2003 13:58:59 -0000
@@ -2134,7 +2134,7 @@ void Buffer::changeLanguage(Language con
 
        ParIterator end = par_iterator_end();
        for (ParIterator it = par_iterator_begin(); it != end; ++it)
-               (*it)->changeLanguage(params, from, to);
+               it->changeLanguage(params, from, to);
 }
 
 
@@ -2148,7 +2148,7 @@ bool Buffer::isMultiLingual()
 {
        ParIterator end = par_iterator_end();
        for (ParIterator it = par_iterator_begin(); it != end; ++it)
-               if ((*it)->isMultiLingual(params))
+               if (it->isMultiLingual(params))
                        return true;
 
        return false;
@@ -2195,7 +2195,7 @@ ParIterator Buffer::getParFromID(int id)
        }
 
        for (; it != end; ++it)
-               if ((*it)->id() == id)
+               if (it->id() == id)
                        return it;
 
        return end;
@@ -2204,8 +2204,8 @@ ParIterator Buffer::getParFromID(int id)
 
 bool Buffer::hasParWithID(int id) const
 {
-       ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
-       ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
+       ParConstIterator it = par_iterator_begin();
+       ParConstIterator end = par_iterator_end();
 
        if (id < 0) {
                // John says this is called with id == -1 from undo
@@ -2214,7 +2214,7 @@ bool Buffer::hasParWithID(int id) const
        }
 
        for (; it != end; ++it)
-               if ((*it)->id() == id)
+               if (it->id() == id)
                        return true;
 
        return false;
Index: iterators.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.C,v
retrieving revision 1.13
diff -u -p -r1.13 iterators.C
--- iterators.C 4 Jun 2003 12:45:25 -0000       1.13
+++ iterators.C 11 Jun 2003 13:58:59 -0000
@@ -47,7 +47,7 @@ public:
 ParPosition::ParPosition(ParagraphList::iterator p, ParagraphList const & pl)
        : pit(p), plist(&pl)
 {
-       if (p != const_cast<ParagraphList&>(pl).end()) {
+       if (p != pl.end()) {
                it.reset(p->insetlist.begin());
        }
 }
@@ -129,7 +129,7 @@ ParIterator & ParIterator::operator++()
                }
 
                // Try to go to the next paragarph
-               if (next(p.pit) != const_cast<ParagraphList*>(p.plist)->end()
+               if (next(p.pit) != p.plist->end()
                    || pimpl_->positions.size() == 1) {
                        ++p.pit;
                        p.index.reset();
@@ -145,7 +145,13 @@ ParIterator & ParIterator::operator++()
 }
 
 
-ParagraphList::iterator ParIterator::operator*() const
+Paragraph & ParIterator::operator*() const
+{
+       return *pimpl_->positions.back().pit;
+}
+
+
+ParagraphList::iterator ParIterator::pit() const
 {
        return pimpl_->positions.back().pit;
 }
@@ -247,7 +253,7 @@ ParConstIterator & ParConstIterator::ope
                }
 
                // Try to go to the next paragarph
-               if (next(p.pit) != const_cast<ParagraphList*>(p.plist)->end()
+               if (next(p.pit) != p.plist->end()
                    || pimpl_->positions.size() == 1) {
                        ++p.pit;
                        p.index.reset();
@@ -264,13 +270,19 @@ ParConstIterator & ParConstIterator::ope
 }
 
 
-ParagraphList::iterator ParConstIterator::operator*() const
+Paragraph const & ParConstIterator::operator*() const
+{
+       return *pimpl_->positions.back().pit;
+}
+
+
+ParagraphList::const_iterator ParConstIterator::pit() const
 {
        return pimpl_->positions.back().pit;
 }
 
 
-ParagraphList::iterator ParConstIterator::operator->() const
+ParagraphList::const_iterator ParConstIterator::operator->() const
 {
        return pimpl_->positions.back().pit;
 }
Index: iterators.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.h,v
retrieving revision 1.11
diff -u -p -r1.11 iterators.h
--- iterators.h 4 Jun 2003 12:45:25 -0000       1.11
+++ iterators.h 11 Jun 2003 13:58:59 -0000
@@ -29,12 +29,14 @@ public:
        ///
        ParIterator & operator++();
        ///
-       ParagraphList::iterator operator*() const;
+       Paragraph & operator*() const;
        ///
        ParagraphList::iterator operator->() const;
        ///
        ParagraphList::iterator outerPar() const;
        ///
+       ParagraphList::iterator pit() const;
+       ///
        ParagraphList & plist() const;
        ///
        size_t size() const;
@@ -64,11 +66,13 @@ public:
        ///
        ParConstIterator & operator++();
        ///
-       ParagraphList::iterator operator*() const;
+       ParagraphList::const_iterator pit() const;
        ///
-       ParagraphList::iterator operator->() const;
-
+       Paragraph const & operator*() const;
        ///
+       ParagraphList::const_iterator operator->() const;
+
+       /// depth of nesting
        size_t size() const;
        ///
        friend
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.451
diff -u -p -r1.451 lyxfunc.C
--- lyxfunc.C   11 Jun 2003 11:01:33 -0000      1.451
+++ lyxfunc.C   11 Jun 2003 13:58:59 -0000
@@ -1363,18 +1363,18 @@ void LyXFunc::dispatch(FuncRequest const
                                            << id << ']' << endl;
                        break;
                } else {
-                       lyxerr[Debug::INFO] << "Paragraph " << (*par)->id()
+                       lyxerr[Debug::INFO] << "Paragraph " << par->id()
                                            << " found." << endl;
                }
 
                if (view()->theLockingInset())
                        view()->unlockInset(view()->theLockingInset());
-               if ((*par)->inInset()) {
+               if (par->inInset()) {
                        FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
-                       (*par)->inInset()->localDispatch(cmd);
+                       par->inInset()->localDispatch(cmd);
                }
                // Set the cursor
-               view()->getLyXText()->setCursor(*par, 0);
+               view()->getLyXText()->setCursor(par.pit(), 0);
                view()->switchKeyMap();
                owner->view_state_changed();
 
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.366
diff -u -p -r1.366 text.C
--- text.C      7 Jun 2003 17:45:41 -0000       1.366
+++ text.C      11 Jun 2003 13:58:59 -0000
@@ -770,8 +770,7 @@ pos_type addressBreakPoint(pos_type i, P
 };
 
 
-pos_type
-LyXText::rowBreakPoint(Row const & row) const
+pos_type LyXText::rowBreakPoint(Row const & row) const
 {
        ParagraphList::iterator pit = row.par();
 
@@ -800,7 +799,7 @@ LyXText::rowBreakPoint(Row const & row) 
        // or the end of the par, then choose the possible break
        // nearest that.
 
-       int const left = leftMargin(const_cast<Row&>(row));
+       int const left = leftMargin(row);
        int x = left;
 
        // pixel width since last breakpoint
Index: toc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/toc.C,v
retrieving revision 1.20
diff -u -p -r1.20 toc.C
--- toc.C       29 May 2003 01:13:17 -0000      1.20
+++ toc.C       11 Jun 2003 13:58:59 -0000
@@ -94,8 +94,8 @@ TocList const getTocList(Buffer const * 
 
                // For each paragraph, traverse its insets and look for
                // FLOAT_CODE or WRAP_CODE
-               InsetList::iterator it = pit->insetlist.begin();
-               InsetList::iterator end = pit->insetlist.end();
+               InsetList::const_iterator it = pit->insetlist.begin();
+               InsetList::const_iterator end = pit->insetlist.end();
                for (; it != end; ++it) {
                        if (it->inset->lyxCode() == Inset::FLOAT_CODE) {
                                InsetFloat * il =
Index: frontends/controllers/ControlErrorList.C
===================================================================
RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlErrorList.C,v
retrieving revision 1.5
diff -u -p -r1.5 ControlErrorList.C
--- frontends/controllers/ControlErrorList.C    22 May 2003 08:01:41 -0000      1.5
+++ frontends/controllers/ControlErrorList.C    11 Jun 2003 13:58:59 -0000
@@ -54,15 +54,12 @@ string const & ControlErrorList::name()
 
 void ControlErrorList::goTo(int item)
 {
-       BufferView * const bv = kernel().bufferview();
-       Buffer * const buf = kernel().buffer();
-
        ErrorItem const & err = errorlist_[item];
 
-
        if (err.par_id == -1)
                return;
 
+       Buffer * const buf = kernel().buffer();
        ParIterator pit = buf->getParFromID(err.par_id);
 
        if (pit == buf->par_iterator_end()) {
@@ -72,14 +69,15 @@ void ControlErrorList::goTo(int item)
 
        int range = err.pos_end - err.pos_start;
 
-       if (err.pos_end > (*pit)->size() || range <= 0)
-               range = (*pit)->size() - err.pos_start;
+       if (err.pos_end > pit->size() || range <= 0)
+               range = pit->size() - err.pos_start;
 
        // Now make the selection.
+       BufferView * const bv = kernel().bufferview();
        bv->insetUnlock();
        bv->toggleSelection();
        bv->text->clearSelection();
-       bv->text->setCursor(*pit, err.pos_start);
+       bv->text->setCursor(pit.pit(), err.pos_start);
        bv->text->setSelectionRange(range);
        bv->toggleSelection(false);
        bv->fitCursor();

Reply via email to