diff --git a/src/ChangeLog b/src/ChangeLog index 585dd409ee..bf6a53afaf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ + +2003-05-05 André Pönitz + + * iterator.C: + * undo_funcs.C: use getParagraphs() instead of getFirstParagraph() + 2003-05-02 Michael Schmitt * bufferparams.C: Output warning if a document with missing diff --git a/src/insets/inset.h b/src/insets/inset.h index 9f7aafa3c5..a1e36f39c8 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -29,6 +29,7 @@ class Painter; class LyXText; class LyXLex; class Paragraph; +class ParagraphList; class LyXCursor; class FuncRequest; class WordLangTuple; @@ -267,7 +268,7 @@ public: virtual Inset * getInsetFromID(int /*id*/) const { return 0; } /// if this insets owns paragraphs (f.ex. InsetText) then it /// should return it's very first one! - virtual Paragraph * getFirstParagraph(int /*num*/) const { return 0; } + virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; } /// virtual bool haveParagraphs() const { return false; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 9c8d1ac446..5f5da107d4 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -571,9 +571,9 @@ int InsetCollapsable::scroll(bool recursive) const } -Paragraph * InsetCollapsable::getFirstParagraph(int i) const +ParagraphList * InsetCollapsable::getParagraphs(int i) const { - return inset.getFirstParagraph(i); + return inset.getParagraphs(i); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index f5b05f6211..b1d84ce018 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -142,7 +142,7 @@ public: /// Inset * getInsetFromID(int id) const; /// - Paragraph * getFirstParagraph(int) const; + ParagraphList * getParagraphs(int) const; /// LyXCursor const & cursor(BufferView *) const; /// diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 0d1ec66543..155d53fad2 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2522,10 +2522,10 @@ void InsetTabular::getSelection(int & srow, int & erow, } -Paragraph * InsetTabular::getFirstParagraph(int i) const +ParagraphList * InsetTabular::getParagraphs(int i) const { return (i < tabular->GetNumberOfCells()) - ? tabular->GetCellInset(i)->getFirstParagraph(0) + ? tabular->GetCellInset(i)->getParagraphs(0) : 0; } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 176e8daf0f..116c5a73b0 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -195,7 +195,7 @@ public: /// Inset * getInsetFromID(int id) const; /// - Paragraph * getFirstParagraph(int) const; + ParagraphList * getParagraphs(int) const; /// LyXCursor const & cursor(BufferView *) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 3b2231bd47..3ada4ab47c 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -2382,9 +2382,9 @@ void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const } -Paragraph * InsetText::getFirstParagraph(int i) const +ParagraphList * InsetText::getParagraphs(int i) const { - return (i == 0) ? &*(paragraphs.begin()) : 0; + return (i == 0) ? const_cast(¶graphs) : 0; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index b2dc28b551..7521131001 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -198,7 +198,7 @@ public: /// Inset * getInsetFromID(int id) const; /// - Paragraph * getFirstParagraph(int) const; + ParagraphList * getParagraphs(int) const; /// LyXCursor const & cursor(BufferView *) const; /// diff --git a/src/iterators.C b/src/iterators.C index 6622fd31ac..9521313243 100644 --- a/src/iterators.C +++ b/src/iterators.C @@ -10,9 +10,9 @@ ParIterator & ParIterator::operator++() // Does the current inset contain more "cells" ? if (p.index >= 0) { ++p.index; - Paragraph * par = p.it.getInset()->getFirstParagraph(p.index); - if (par) { - positions.push(ParPosition(par)); + ParagraphList * plist = p.it.getInset()->getParagraphs(p.index); + if (plist && !plist->empty()) { + positions.push(ParPosition(&plist->front())); return *this; } ++p.it; @@ -25,10 +25,10 @@ ParIterator & ParIterator::operator++() // Try to find the next inset that contains paragraphs InsetList::iterator end = p.par->insetlist.end(); for (; p.it != end; ++p.it) { - Paragraph * par = p.it.getInset()->getFirstParagraph(0); - if (par) { + ParagraphList * plist = p.it.getInset()->getParagraphs(0); + if (plist && !plist->empty()) { p.index = 0; - positions.push(ParPosition(par)); + positions.push(ParPosition(&plist->front())); return *this; } } @@ -52,9 +52,9 @@ ParConstIterator & ParConstIterator::operator++() // Does the current inset contain more "cells" ? if (p.index >= 0) { ++p.index; - Paragraph * par = p.it.getInset()->getFirstParagraph(p.index); - if (par) { - positions.push(ParPosition(par)); + ParagraphList * plist = p.it.getInset()->getParagraphs(p.index); + if (plist && !plist->empty()) { + positions.push(ParPosition(&plist->front())); return *this; } ++p.it; @@ -67,10 +67,10 @@ ParConstIterator & ParConstIterator::operator++() // Try to find the next inset that contains paragraphs InsetList::iterator end = p.par->insetlist.end(); for (; p.it != end; ++p.it) { - Paragraph * par = p.it.getInset()->getFirstParagraph(0); - if (par) { + ParagraphList * plist = p.it.getInset()->getParagraphs(0); + if (plist && !plist->empty()) { p.index = 0; - positions.push(ParPosition(par)); + positions.push(ParPosition(&plist->front())); return *this; } } diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 24d4571d6c..71467a6daf 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -17,7 +17,6 @@ #include "insets/insettext.h" #include "debug.h" #include "support/LAssert.h" - #include "iterators.h" #include @@ -51,11 +50,11 @@ Paragraph * firstUndoParagraph(BufferView * bv, int inset_id) { Inset * inset = bv->buffer()->getInsetFromID(inset_id); if (inset) { - Paragraph * result = inset->getFirstParagraph(0); - if (result) - return result; + ParagraphList * result = inset->getParagraphs(0); + if (result && !result->empty()) + return &result->front(); } - return &*bv->text->ownerParagraphs().begin(); + return &bv->text->ownerParagraphs().front(); }